[SOLVED] Understanding Linux partitions and partitioning commands..
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Understanding Linux partitions and partitioning commands..
Hello Geeks,
I just have a fair knowledge in Linux or may be not.. But i just started exploring it and I'm loving the stuff.
I'm trying to understand the commands used in Arch installation. Please help me with the following :-
1. The following commands :-
mkdir /mnt
mount /dev/sda1 /mnt
mkdir /mnt/home
mount /dev/sda2 /mnt/home
I understand that "mkdir /mnt" creating the directory "/mnt" and its a temporary location of all the storage. But even "/dev" is the same. Why we are not giving command "mkdir /dev". It might be a stupid question. But I'm just learning this.
And please explain these commands :
mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/home
2. Disk partition
Is it necessary to create a seperate root partition and boot partition ? When we create a boot partition we specify it as a boot partition. How about the root partition, If the /boot partition and the /root partition are not to be the same how we mark a partition as root.
/dev is a core part of the install; its not temp/optional. All devices have a /dev entry, not just disks.
The mount cmds mount the disk partitions at the dirs specified.
IOW, dirs are just inodes, but you need physical space to store actual files.
A partition can be mounted at almost any dir, but you'd avoid a lot of them, otherwise it masks the existing dirs.
You don't need separate /boot and '/' (aka root partition) partitions; its optional. However, /boot partitions must be marked as bootable for the BIOS to recognise it. https://en.wikipedia.org/wiki/Master_boot_record
If you use the cmd
Code:
fdisk -l
(lowercase L there) then you'll see the disk partitions layout. The bootable one is usually marked with *.
You use
Code:
df -hT
to see the dir mount points and filesystem types.
See also the content of the /etc/fstab file.
Wow !! that was such a quick response.. Thank you soo much.
So If I want seperate /boot and '/', then the /boot partition will be marked with a *, but how will we tell it to use the boot partion as the root partition ?
However, /boot partitions must be marked as bootable for the BIOS to recognise it.
False. The Linux partition that contains or is /boot almost never needs to be marked as bootable. It can even be a logical partition (which cannot even be temporarily flagged as bootable).
Also the BIOS normally does not recognize nor care about the bootable flag on partitions.
The bootable flag matters to Microsoft MBR code and to Windows itself. It does not matter to Linux (Grub) MBR code nor to Linux itself.
In theory, you could put the first part of grub in the partition boot sector (instead of in the MBR) and put Microsoft code in the MBR and flag the Linux partition bootable, so Microsoft MBR code would directly load Grub. By I can't think of why anyone would want such a kludge.
The usual reason to put the first part of grub in the partition boot sector is to let it be chain loaded from Windows or some other Linux boot system. When it is chain loaded, it does not need to be marked bootable.
If you put the first part of grub in the MBR, then there is no reason for any Linux partition to be marked bootable. If you also have a Windows C: partition (and Grub can chain load Windows) then you need the Windows C: partition either permanently or dynamically flagged as bootable (even though it is not the partition that actually boots first).
Quote:
Originally Posted by anup1304
So If I want seperate /boot and '/', ... how will we tell it to use the boot partion as the root partition ?
I can't understand what relationship you intend for those two phrases: As mutually exclusive alternatives or the second follows from the first. Either way the question doesn't quite make sense.
If you don't make /boot a separate partition, then the Linux installer will automatically make /boot a directory inside /
The first part of Grub needs to be installed somewhere (typically the MBR) and the location of /boot is automatically encoded into that first part of Grub.
Quote:
Originally Posted by anup1304
If the /boot partition and the /root partition are not to be the same how we mark a partition as root.
Regardless of whether /boot is a separate partition, the config file inside /boot must explicitly tell grub which partition should be /
Even if /boot is a directory inside / the config file in /boot still needs to identify the partition to be used as /
That makes more sense if you remember Grub is a multi-boot system. If you have multiple Linux installs in different partitions, a config file in one /boot directory in one Linux install can give menu choices and associated boot command for all of the Linux partitions.
I kind of not getting just one part. What is the significance of creating a logical partition ? I have to create the boot partition as a primary partition, just like in Windows, C drive is a primary partition and the rest of the drives are secondary and logical. But in Windows , the OS itself marks the partition as primary or logical. How does that work in Linux ?
What is the significance of creating a logical partition ?
The legacy data structure used for partitioning only allows 4 "primary" partitions and if you have any logical partitions then one of the four primary positions is taken for a wrapper around the logical partitions.
Quote:
I have to create the boot partition as a primary partition
Ok looking at my machine, looks like I got carried away there. Some 'boot' partitions are marked, one isn't, but it still works.
Guess I've seen it so often as marked I forgot its not strictly required.
A device name like /dev/sda1 is a name that the kernel has chosen to give a certain partition after detecting the presence of that device. Now in order to read/write files & folders on the partition, the file system on that partition must be made available within the overall (root) file system, i.e., it must be mounted, so the file system driver for that partition type (can be anything, also like NTFS) is activated and deals with the partition properly.
To access the contents of that partition, you need a mount point, i.e., a (usually empty) directory somewhere, like e.g. /mnt/my_windows_c/ or /home. Then you run "mount /dev/sda1 /mnt/my_windows_c" (or "mount /dev/sda1 /home") et voila, you can access all the files & folders on the device named /dev/sda1 in the chosen mountpoint (directory).
There are no separate "drive" letters, totally separate from each other. Instead, all partitions are mounted somewhere in a folder in the root partition (tree), which is "/". E.g. the boot partition (if you have decided to use a separate one) is then usually mounted in /boot, and so on.
About "primary" / "extended" partitions and "logical drives": as for historical reasons, the good-old msdos partition scheme (which is still widely used even on Linux systems, although there are more modern alternatives), can only define up to 4 partitions (primary partitions). That's it. Now as we meanwhile often need more than 4 partitions, an extension was added to the msdos partition scheme that allows to declare the last of all defined partitions (can be any partition from 1 to 4) as a so-called "extended" partition with a simple flag, which is merely a pseudo partition that spans over the rest of the entire harddisk. But then, within the extended partition, further "logical" partitions can be defined inside the extended partition, so the former 4-partition limit could eventually be overcome..
Wow !! that was such a quick response.. Thank you soo much.
So If I want seperate /boot and '/', then the /boot partition will be marked with a *, but how will we tell it to use the boot partion as the root partition ?
Here's what my Windows and Linux partitions on my machine to give you an idea of what all partitions look like-
Device Boot Start End Blocks Id System
/dev/sda1 1 463 3719016 12 Compaq diagnostics
/dev/sda2 * 464 18273 143052491+ 7 HPFS/NTFS
/dev/sda3 18273 20826 20507649 5 Extended
/dev/sda5 18273 20704 19530752 83 Linux
/dev/sda6 20704 20826 975872 82 Linux swap / Solaris
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.