Page 1 of 1

[THE 1st TIME] Disk partitioning pt. 1

Posted: Mon Feb 24, 2014 2:37 am
by machinebacon
The most scary part in every Linux installation is the disk partitioning. Enter the wrong stuff and your beloved #! gets deleted, and Windows does not boot anymore.

Let's see how a typical distrohopper's disk layout would look like:

Code: Select all

bbq@grill:~$ sudo blkid -o list
device              fs_type     label        mount point             UUID
----------------------------------------------------------------------------------------------------------
/dev/sda1           ext4                     /media/sda1             888ad3c6-4bc1-4089-b4f4-c32a6a33c0bd
/dev/sda5           ext4                     /                       7dd68644-0f72-434e-b5fc-8381f0424f91
/dev/sda3           ext4                     /media/sda3             e26a7d33-98b8-49f7-8e64-90eb1b7965e0
/dev/sda6           ext4                     /media/sda6             f8cfc4d3-8542-4b04-89fc-cef2ef07a821
/dev/sda7           ext4                     /media/sda7             62769535-815c-4ff6-a156-840e24f0a40d
/dev/sda8           ext4                     /media/sda8             2b1c7764-f2b0-4064-8f7d-1798c208fc74
/dev/sda9           ext4                     /media/sda9             98a423e2-4920-414f-acad-c855fdf4c617
As we can see, the /dev/sda5 is the 'root' partition, the one in which we are now, marked with the mount point '/'. We can also see that all other partitions are Linux installations. There is no swap space designated. Good guy! Is there a Windows installation? No, because we don't see "NTFS" listed as filesystem type.

And what is the partition where GRUB sits?

Code: Select all

bbq@grill:~$ sudo fdisk -l |grep '*'
Units = cylinders of 16065 * 512 = 8225280 bytes
/dev/sda1   *           1         638     5124703   83  Linux
So, apparently /dev/sda1 is the partition that has the 'bootable flag', usually this is also the partition that is responsible for how GRUB looks like. It does not need to be the first partition of your drive. I could now, being in /dev/sda5, simply make this the boot partition (LinuxBBQ users can try the command "sudo grubrepair")

And how do I know what partition has what kind of Linux installed? A dirty trick:

Code: Select all

cat /boot/grub/grub.cfg |grep class|cut -c 80
This command first lists everything in /boot/grub/grub.cfg (the file that prints the GRUB menu on screen), then only shows lines that contain the word 'class', and then finally shows us only 80 characters of each line, for better readability. Of course you should read this from the actual boot partition, so in my case (/dev/sda1) I would first create a mountpoint (luckily I have one already)

Code: Select all

sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1
and then read the file from there:

Code: Select all

cat /media/sda1/boot/grub/grub.cfg |grep class|cut -c 80
Clever people (who never really change the Operating systems in their partitions) can give their partitions some LABELs. I would give, for example, my /dev/sda5 partition the label "WORK", because I use this one mostly for, well, work.

Code: Select all

e2label /dev/sda5 WORK
and check the outcome. How? Read this post again from top to down ;)

Do this labeling with all your ext filesystem type (!) drives and partitions -- so everything that is ext2, ext3 or ext4, and you will feel a little bit more comfortable when you enter part 2 of this HOWTO :)

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Mon Feb 24, 2014 4:28 am
by ivanovnegro
The labeling is an awesome idea.

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Mon Feb 24, 2014 6:04 pm
by johnraff
bookmarked

Partition labels are very useful. Save you a lot of work sometimes.

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Tue Feb 25, 2014 12:59 pm
by kiiroitori
Very good stuff Sir Bacon, the 1st time can be stressful so this kind of info is gold ! Thank you!

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Fri Oct 07, 2016 12:39 am
by catfood
A few things that helped me sort partitions out too:

Take a screenshot of gparted or lsblk. Edit image and type distro names next to each. I store this on my nfts music partition where I know i wont lose it. Can update as i change this easy.

Also, all my partitions are slightly different sizes to help remember. Debian 33G, others 32,34, or lightweights 8,9,10. Similar sizes based on intended use, but 1GB difference just sticks in your mind easier when you try to remeber in the middle of a new install.

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Fri Oct 07, 2016 12:58 am
by pidsley
^ good idea

Or use "e2label" to label the partitions:

Code: Select all

$ sudo e2label /dev/sda1 "jessie"
and then "blkid" to list when you forget:

Code: Select all

$ sudo blkid -s LABEL
/dev/sda1: LABEL="jessie"
/dev/sda5: LABEL="trisquel lxde" 
/dev/sda8: LABEL="shared" 
/dev/sda9: LABEL="LFS" 
/dev/sda12: LABEL="export" 
/dev/sda13: LABEL="anorexia" 
/dev/sda17: LABEL="cardboard" 
/dev/sda18: LABEL="ceramic" 
Or take the lazy way out like me and just write them on a piece of paper (in pencil so you can erase and change as necessary.)

(-:

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 3:57 am
by sgtbigman
Or take the lazy way out like me and just write them on a piece of paper (in pencil so you can erase and change as necessary.)
I'm now picturing a chalkboard with your partition layout and labels :D

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 9:44 am
by wuxmedia
Had to be (badly) done:
..and what's wrong with Trisquel?
..and what's wrong with Trisquel?
gawd that is bad. touchpad for drawing- not good :(

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 1:58 pm
by machinebacon
^ haha that's excellent!

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 5:03 pm
by catfood
I used to do paper notes, but now i have a mountain of paper notes crammed in cd binder pocket. Unsure whats even relevant anymore...

A giant partition chalkboard would be the final blow to my sex life. If computer part nintendo dungeon didnt already scare them off, super chalkboard would do it.

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 5:57 pm
by machinebacon
^ whiteboard for the win. I got a few whiteboard markers with which I write some notes on the tiles in my kitchen. Super clean thing. No fdisk output there, yet :D

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sat Oct 08, 2016 9:54 pm
by catfood
An artistic way to do it...

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sun Oct 09, 2016 4:00 am
by machinebacon
^ I'm just a cheapo, whiteboards cost moneh :)

Re: [THE 1st TIME] Disk partitioning pt. 1

Posted: Sun Oct 09, 2016 8:22 am
by darry1966
Nice work MB appreciate the time and effort you put into your documentation.:)