Ubuntu – How to partition the hard drive for Ubuntu use


Till now I was windows user. From now on I want to use only Linux.

I have 500Gb HDD. How do I partition it properly? I read that there is no right or wrong way, but still, I am confused. I did something and I have primary partition mounted on / (160Gb) which I believe is a OS and 350Gb extended partition of which I have 4Gb of swap and 346Gb mounted on /home.

I got used to C:\ and D:\ partitioning, but I don't see file system in that way. I am lost. Where is what? How can I make C:\ partition for OS and D:\ for apps, movies, music, photos. Or what I want is Windows way and I have to get used to Linux way?

Best Answer

Linux is not all that different to MS-Windows:

Gnu/Linux an improved and Free Unix. MS-Windows is based on MS-Dos that is a poor clone of CPM that was inspired by Unix.

There is one main difference: Gnu/Linux and all Unixes have one root, one unified hierarchy, and therefore no drive letters. MS-Windows, DOS and CPM have multiple hierarchies, one for each drive/partition, they are given letters (e.g. c:). On Gnu/Linux home will be mounted on /home, it will be there no matter if it is on the same partition, a separate partition or a network share. The advantage of this approach is that the name of files is not dependant on the location of the storage device. The advantage of the Ms-Windows, dos, cpm way is that is was easier for the operating system programmers when they wrote the operating system.

Sub-trees (from other partition, disks or network share etc. ) can be grafted on, but there is one tree per computer. You can even share sub-trees between computers using network file shares, but they are sub-trees not new trees.

Type mount -l on a command line to see all mounts. Note this includes a few special mounts that have no backing store. Also df -h to get usage info.

Example from my system:

#how full are my filesystems.
df -h --print-type 
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda5     ext4     20G  9.7G  8.7G  53% /
tmpfs        tmpfs    1.5G     0  1.5G   0% /lib/init/rw
udev         tmpfs    1.5G  284K  1.5G   1% /dev
tmpfs        tmpfs    1.5G  4.0K  1.5G   1% /dev/shm
/dev/sda6     ext4     87G   64G   18G  79% /home
/dev/sdb2     ext4    230G   85G  133G  39% /media/extra

#detailed info on what is mounted, but no size or usage info.
mount -l
/dev/sda5 on / type ext4 (rw,dirsync,errors=remount-ro,barrier=1,data=journal,auto_da_alloc,journal_checksum) [debian]
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/sda6 on /home type ext4 (rw,dirsync,errors=remount-ro,barrier=1,data=journal,auto_da_alloc,journal_checksum) [debian-home]
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
/dev/sdb2 on /media/extra type ext4 (rw,nosuid,nodev,uhelper=udisks) [extra]
  • The root file-system / [equivelent to c:] is on primary hard-disk partition.
  • On /lib/init/rw we have a temporary ram based file system. (probably used by init, process 1, probably best it ignore it)
  • on /proc we have the proc file-system. This is magic, it is a dynamic file-system, it can tell you lots of cool stuff about you processes/system.
  • on /sys we have the sys file-system. (see what I said about /proc)
  • on /dev we have udev. udev manages /dev. /dev is a where lots of magic lives, lots of things that you may not think of as files live there: partitions, audio/video input output, keyboard, mouse, a black-hole (/dev/null), a source of nothing (/dev/zero), etc.
  • on /home is another disk partition. This is where users directories are. [Equivalent to ?:\User on modern Microsoft os, where ? may be C, or something else].
  • on /media/extra is an external hard-disk. /media is a place that external drives get mounted on automatically. In /media is also a directories /media/cdrom and /media/cdrom0 the first a reference to the other. They are empty directories, but if I put in a cdrom. Then the cd appears here. [ Equivalent to random-letter-of-the-day:\]

more examples:

#what swap have I got, and what is being used.
/sbin/swapon -s
Filename        Type        Size      Used   Priority
/dev/sda7       partition   4095992   0      -1

#what disks and partitions have I got.
ls -l /dev/disk/by-path/*
lrwxrwxrwx 1 root root  9 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:1.1:1.0-scsi-0:0:0:0 -> ../../sdb
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1d.7-usb-0:1.1:1.0-scsi-0:0:0:0-part2 -> ../../sdb2
lrwxrwxrwx 1 root root  9 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root 10 Jul 15 22:39 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part3 -> ../../sda3
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part5 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part6 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0-part7 -> ../../sda7
lrwxrwxrwx 1 root root  9 Jul 15 19:36 /dev/disk/by-path/pci-0000:00:1f.2-scsi-1:0:0:0 -> ../../sr0

/dev is the directory that raw devices live in. /dev/sd* are disk partitions. /dev/sda is primary hard disk /dev/sdb is secondary hard disk in my case an external one. /dev/sd?1 is first partition of a disk. 1,2,3,4 are primary partitions, 5,6,7,etc are secondary partitions.