## page was renamed from BeginnersTeam/FocusGroups/Education/Events/02072009 #title Beginners Team Education Focus Group ## ##Please use the following icons ##Tutorial - {{attachment:IconsPage/32pixel/32linuxhw.png}} ##General Knowledge - {{attachment:IconsPage/32pixel/32books.png}} ##Security Related - {{attachment:IconsPage/32pixel/32neotux.png}} ##Terminal Used - {{attachment:IconsPage/32pixel/32term.png}} ## ##List items can have multiple icons associated with them ## ##If you need more icons added please contact PrivateVoid <> ----- ==== Saturday the 7th ==== '''IRC Question and Answer Session'''<
> '''topic''': Partitioning - Part Two<
> '''date''': 7^th^ February 2009<
> '''time''': start 1330 UTC end 1430 UTC<
> '''location''': IRC - #ubuntu-classroom on freenode.net<
> {{attachment:IconsPage/32pixel/32books.png}} {{attachment:IconsPage/32pixel/32term.png}} Partitioning from a terminal Session 2 * Command line partitioning * fstab * chmod and chown ==== Notes ==== * We will be making use of a [[https://wiki.ubuntu.com/BeginnersTeam/FocusGroups/Education/STS|shared terminal ]] please make sure that you are connected before the session begins - the shared session will be set up approximately 30 minutes prior to the start time 1330UTC. * It will be of some help if you visit this [[http://www.ss64.com/bash/chmod.html|chmod]] page and practise changing permissions to see the read, write and execute permissions change. * If possible please look at the NTFS and FAT32 permissions section on this [[https://help.ubuntu.com/community/Fstab|fstab]] wiki page. * The expected output from the shared terminal is shown below prior to the 7th February, please try and look through this prior to the session start to orientate yourself. === logs === ==== IRC Logs ==== {{{ [07:Feb]:13:31 Ok - then this is the fdisk/fstab/chmod and chown session [07:Feb]:13:31 This session Is moderated‭ – ‬this means that you won't be able to talk until you have been voiced,‭ ‬you can ‭ /msg PArtyBoi2 and he can voice you in turn [07:Feb]:13:31* forestpixie sets mode +m #ubuntu-classroom [07:Feb]:13:32 Right then, to the session proper‭ ‬-‭ ‬I intend to first work through using fdisk which is a command line partition tool and then to format our new partitions. [07:Feb]:13:32 We'll follow that with a question/answer session [07:Feb]:13:32 Then‭ ‬we will take a look at the fstab file,‭ ‬this file gives static information about partitions we wish to mount on boot [07:Feb]:13:33 We will be looking at our own fstab files in relation to the‭ ‬/‭ ‬and swap partitions and then write the lines needed to mount our new partitions‭ ‬,once again following that we will have a Q&A session‭ [07:Feb]:13:33 The final part of the session will look at the chmod and chown commands,‭ ‬chmod can be used to change permissions on files,‭ ‬chown can be used to change file ownership.‭ [07:Feb]:13:35 Ok - fdisk first, a little bit more here then we can look at the virtual terminal [07:Feb]:13:36 I am going to create the following partitions‭ ‬,‭ ‬2‭ ‬primaries,‭ ‬1‭ ‬extended and a logical inside it. [07:Feb]:13:36 You start fdisk with root rights on the device you wish to work with [07:Feb]:13:36 sudo fdisk‭ ‬/dev/sxy‭ – ‬the number of the drive can be found by using fdisk -l‭ – ‬check the virtual terminal [07:Feb]:13:37 You can see that it has listed 2 drives - we are going to use /dev/sdb‭ [07:Feb]:13:37 so we will start fdisk on that drive [07:Feb]:13:38 m will givce you all the commands you can use here [07:Feb]:13:38 To create a new drive use‭ '‬n‭' ‬it then asks us what type of partition we want,‭ ‬I want the first partition to be a primary,‭ ‬so to create a primary we use‭ '‬p‭' [07:Feb]:13:39 Now we need to tell fdisk which partition we want to create,‭ ‬I want it to be number‭ 1 [07:Feb]:13:39 I am going to use cylinders to set up the sizes of the partitions‭ – ‬we can see from the previous fdisk output that the whole drive is 652 cyclinders in size. I used the default setting for the first cylinder of this partition [07:Feb]:13:39 Now I need to specify where the partition ends,‭ ‬for the first partition I use‭ ‬200‭ ‬as I want the partition to be‭ ‬that many cylinders in size [07:Feb]:13:39 I could if I wanted create the partition using a number to give it a size,‭ ‬you use G for Gb,‭ ‬M for Mb or K for Kb [07:Feb]:13:40 Finally I need to tell fdisk to complete the operation and write the new partition table,‭ ‬to do this use‭ w [07:Feb]:13:40 If I use fdisk‭ ‬-l it should now show me my new partition, [07:Feb]:13:41 Ok I will now proceed to create the remaining partitions.‭ ‬First‭ ‬1‭ ‬more primary and then the extended with it's associated logical,‭ ‬this time I will make all the new partitions and then write the table at the end [07:Feb]:13:42 Now that I have an extended that choice is no longer possible,‭ ‬so now we can only create primaries or logical as you will see,‭ ‬further once fdisk knows I wish to create a logical it will only allow me to create it within the extended partition [07:Feb]:13:44 Ok so we now have our partitions created - at the moment they are all needing filesystems, before we do that I'll stop and you can tell me if I was to slow or fast :) [07:Feb]:13:44* forestpixie sets mode -m #ubuntu-classroom [07:Feb]:13:45 if you have any questions - ask now [07:Feb]:13:45* forestpixie sets mode +m #ubuntu-classroom [07:Feb]:13:46 on to creating the filesystems then - so back and forth between here and the terminal [07:Feb]:13:46 We can use the mkfs,‭ ‬mkdosfs and mkntfs‭ ‬commands here to accomplish this‭ ‬,‭ ‬the syntax to use this command is similar for all‭ ‬3 [07:Feb]:13:46 sudo mkfs‭ ‬-t filetype‭ ‬/dev/sdxy , So the commands we will need to run in our vt are [07:Feb]:13:48 Ok we now have our created our new partitions and formatted them. [07:Feb]:13:49 As ther are no questions I'll carry on with fstab [07:Feb]:13:50 If you run cat /etc/fstab in a normal terminal you will see this at the top [07:Feb]:13:50 [07:Feb]:13:51 This is part of my fstab relating to my‭ ‬/‭ ‬partition‭ [07:Feb]:13:51* forestpixie gives voice to PartyBoi2 [07:Feb]:13:51 UUID‭=‬9d44e64b-0c3f-4376-93f5-7e0a4bc9afac‭ ‬/‭ ‬ext3‭ ‬relatime,errors=remount-ro‭ ‬0‭ ‬1‭ [07:Feb]:13:51 OK,‭ ‬so now lets have a look at the fstab line in some more detail and then finally we can look at creating a new line.‭ [07:Feb]:13:52 The first part to the UUID,‭ ‬you can if you wish use the device name instead of UUID‭ [07:Feb]:13:52 to do so I would replace it with‭ ‬/dev/sda2‭ ‬this would make my fstab line read so‭ [07:Feb]:13:52 /dev/sda2‎ ‏/‎ ‏ext3‭ ‬relatime,errors=remount-ro‭ ‬0‭ ‬1‭ [07:Feb]:13:52 The advantage of using the UUID lies in it not changing unless a change is made to the partition itself,‭ ‬creating,‭ ‬removing or resizing other partitions doesn't affect the UUID of unaffected partitions.‭ [07:Feb]:13:52 The next part of the line‭ ‬-‭ ‬/‭ ‬tells the system where we want our partition to mount,‭ ‬this partition is my install so I want it mounting as root‭ [07:Feb]:13:53 Following the mount point is the filesystem type‭ ‬-‭ ‬mine is ext3,‭ ‬if you have a default installation yours should be the same,‭ ‬if you have any ntfs drives mounting then that would read ntfs or maybe ntfs-3g [07:Feb]:13:53 After the filesystem,‭ ‬any options are indicated,‭ ‬here relatime is the first option followed by the errors=remount-ro option‭ ‬-‭ ‬this second option is the one which will cause the system to remount the partition as read only [07:Feb]:13:53 The next section is set as‭ ‬0‭ ‬-‭ ‬this is the dump option and relates to whether the filesystem is backed up by dump,‭ ‬0,‭ ‬the default is no. [07:Feb]:13:54 Finally we have the pass section‭ ‬-‭ ‬this is set to‭ ‬1‭ ‬-‭ ‬this controls the order in which a filesystem is checked by fsck,‭ ‬a‭ ‬1‭ ‬means that the partition is checked first,‭ ‬a‭ ‬0‭ ‬would stop the check and a‭ ‬2‭ ‬would mean it was checked last.‭ [07:Feb]:13:55 If there any latecomers can they /msg PartyBoi2 with questions please :) [07:Feb]:13:55 Before we can actually mount any new partitions,‭ ‬we need to have somewhere to mount it,‭ ‬the mountpoint,‭ ‬so we do that by making a folder. [07:Feb]:13:56 I tend to use‭ ‬/mnt for my mounts‭ – ‬if you want the partition to be visible on the desktop then create your folder in‭ ‬/media instead [07:Feb]:13:56 To do that we would use the mkdir command like so [07:Feb]:13:56 sudo mkdir /mnt/foldername [07:Feb]:13:56 So to allow our new partitions to mount correctly I need to create their mountpoints - one for each partition we have created [07:Feb]:13:56 which I need to do no win the shared terminal [07:Feb]:13:58 So now we have the new folders in‭ ‬/mnt to use. [07:Feb]:13:58* forestpixie sets mode -m #ubuntu-classroom [07:Feb]:13:58 db1 - you have a question? [07:Feb]:13:58* PartyBoi2 gives voice to d1b [07:Feb]:13:59 yes what happens if you rename a luks lvm volume -> will it continue to work if you use the uuid in /etc/fstab or do you need to update initrd ? [07:Feb]:14:00 I don't know the answer to that - I've never used them [07:Feb]:14:00 if anyone else does I think you should be able to talk until I set the mode again [07:Feb]:14:02 so we've made our folders in /mnt now we need ot add them to fstab [07:Feb]:14:02 We are going to be editing the file with a terminal based text editor - it's useful to know your way around at least one - if you ever need to edit a file from the recovery menu then I'm afraid that a GUI editor like gedit, kate or mousepad will be of no use. [07:Feb]:14:03 so first we give tell it which partition we are mounting [07:Feb]:14:03 which is /dev/sdb1‭ [07:Feb]:14:03 Next we have to tell it our new mountpoint [07:Feb]:14:04* PartyBoi2 removes voice from d1b [07:Feb]:14:04 ‭/dev/sdb1 /mnt/ext3 [07:Feb]:14:04 Next comes the filetype [07:Feb]:14:04 ‭ /dev/sdb1 /mnt/ext3 ext3 [07:Feb]:14:04 Next come any options you wish to pass‭ – ‬I add user here [07:Feb]:14:05 Finally we come to the dump and pass options,‭ ‬use the default‭ ‬0‭ ‬for the dump and‭ ‬2‭ ‬for the pass option,‭ ‬it is suggested that you allow fsck to check the drive,‭ ‬but if you wished it not to then you would set the pass option to‭ ‬0 - you can change the frequency that fsck checks a drive [07:Feb]:14:05 Now I shall add the lines for our other‭ ‬2‭ ‬partitions,‭ ‬the ntfs and fat32 [07:Feb]:14:06 So that is the data entered into fstab,‭ ‬you would now need to save the file [07:Feb]:14:06 I would now mount to check that the partitions have mounted without any problems [07:Feb]:14:06 Assuming that there is no output on the screen then the partition has mounted.‭ ‬You can check to see with a couple of commands,‭ ‬but df is a bit easier to scan [07:Feb]:14:07 ok - it's possible that there is a apparmor operating on the terminal - I've done this ocne earlier and it worked without issue [07:Feb]:14:09 ok - we have a small problem in the shared terminal :( [07:Feb]:14:09 we can stop for a while for any questions - we are unmoderated so I think you can talk [07:Feb]:14:10 If you have questions ? [07:Feb]:14:10 could you cat /etc/fstab please? [07:Feb]:14:10 yep [07:Feb]:14:10 There is a space before dev/sdb2 [07:Feb]:14:11 huh, weird [07:Feb]:14:12 so there was - pasting from abiword doesn't work as well as openoffice :) [07:Feb]:14:12 the vm is running on jaunty, I think there were some issues when the vm was set up - but he's not about so I can't ask [07:Feb]:14:13 I ran this previously and the log from the session is on the wiki page [07:Feb]:14:13 Maybe there is some invisible character that came with the pasting? [07:Feb]:14:14 possibly I can try doing ti long hand :) [07:Feb]:14:18 thanks you unutbu :) [07:Feb]:14:18 cool [07:Feb]:14:19 ok then we can move on if there are no questions :) [07:Feb]:14:19 Could you do sudo fdisk -l one more time? [07:Feb]:14:19 first we can look at chown - changing ownership of files or folders [07:Feb]:14:20 I think that is the problem we had from the beginning with the vm unutbu [07:Feb]:14:20 ok [07:Feb]:14:21 I have no idea why it shows them all as linux - nor did bodhi [07:Feb]:14:21 when you use fdisk, you can use a command to change the partition type [07:Feb]:14:21 it is interesting that you can proceed without doing so [07:Feb]:14:22 within fdisk the command is 't' [07:Feb]:14:22 to be honest I've only used it a few times in anger - and I rarely have anything to do with win filesystems anymore [07:Feb]:14:22 you can still do it; even on a partition with a filesystem [07:Feb]:14:22 :) lol [07:Feb]:14:23 I can have a look later if you want [07:Feb]:14:23 ok [07:Feb]:14:23 Nearly finished now [07:Feb]:14:23 There are‭ ‬4‭ ‬different permutations available for the owner and group changes [07:Feb]:14:24 so we'll make a folder in our /etx3 partition and change the owner and group to see the changes [07:Feb]:14:25 so we can change the fodler with chown [07:Feb]:14:28 so chown can change the owner or group for a folder or file [07:Feb]:14:28 chmod will change the permissions for files or folders [07:Feb]:14:29 the command is used like [07:Feb]:14:29 chmod 000 /path/to/file [07:Feb]:14:29 the numbers are made from 4, 2 and 1 - giving a combination of read, write and execute [07:Feb]:14:30 ls -al will show the current permissions - the d simply denoting that it is a folder rather than a file [07:Feb]:14:31 at the moment the folder temp has 755 permissions fro group and others - owner has read,write and execute [07:Feb]:14:31 so in the shared session I can change them [07:Feb]:14:33 so once we know the chmod and chown commands we can change the owner and permissions of any file or folder [07:Feb]:14:33 ok - thanks for coming along - that's it for the time being }}} (note: will be posted after the event) ==== Shared Terminal Session transcript ==== Tuesday January 27, 2009 12:05 PM MST 12:05:38 up 12:54, 1 user, load average: 0.00, 0.00, 0.00 Peace be with you root root@ufbt:fdisk -l {{{ Disk /dev/sda: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0004ae6f Device Boot Start End Blocks Id System /dev/sda1 * 1 743 5968116 83 Linux /dev/sda2 744 783 321300 5 Extended /dev/sda5 744 783 321268+ 82 Linux swap / Solaris Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x00000000 Disk /dev/sdb doesn't contain a valid partition table }}} root@ufbt:fdisk /dev/sdb {{{ Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xdf8bc6fe. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-652, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): 200 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. }}} root@ufbt:fdisk -l {{{ Disk /dev/sda: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0004ae6f Device Boot Start End Blocks Id System /dev/sda1 * 1 743 5968116 83 Linux /dev/sda2 744 783 321300 5 Extended /dev/sda5 744 783 321268+ 82 Linux swap / Solaris Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xdf8bc6fe Device Boot Start End Blocks Id System /dev/sdb1 1 200 1606468+ 83 Linux }}} root@ufbt:fdisk /dev/sdb {{{ Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (201-652, default 201): Using default value 201 Last cylinder, +cylinders or +size{K,M,G} (201-652, default 652): 401 Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 3 First cylinder (402-652, default 402): Using default value 402 Last cylinder, +cylinders or +size{K,M,G} (402-652, default 652): Using default value 652 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (402-652, default 402): Using default value 402 Last cylinder, +cylinders or +size{K,M,G} (402-652, default 652): Using default value 652 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. }}} root@ufbt:fdisk -l {{{ Disk /dev/sda: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0004ae6f Device Boot Start End Blocks Id System /dev/sda1 * 1 743 5968116 83 Linux /dev/sda2 744 783 321300 5 Extended /dev/sda5 744 783 321268+ 82 Linux swap / Solaris Disk /dev/sdb: 5368 MB, 5368709120 bytes 255 heads, 63 sectors/track, 652 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0xdf8bc6fe Device Boot Start End Blocks Id System /dev/sdb1 1 200 1606468+ 83 Linux /dev/sdb2 201 401 1614532+ 83 Linux /dev/sdb3 402 652 2016157+ 5 Extended /dev/sdb5 402 652 2016126 83 Linux }}} root@ufbt:mkfs -t ext3 /dev/sdb1 {{{ mke2fs 1.41.3 (12-Oct-2008) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 100464 inodes, 401617 blocks 20080 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=415236096 13 block groups 32768 blocks per group, 32768 fragments per group 7728 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: 0/13 1/13 2/13 3/13 4/13 5/13 6/13 7/13 8/13 9/1310/1311/1312/13 done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. }}} root@ufbt:mkntfs -f /dev/sdb2 {{{ Cluster size has been automatically set to 4096 bytes. Creating NTFS volume structures. mkntfs completed successfully. Have a nice day. }}} root@ufbt:mkdosfs /dev/sdb5 {{{ mkdosfs 3.0.1 (23 Nov 2008) }}} root@ufbt:mkdir /mnt/ntfs /mnt/fat32 /mnt/ext3 root@ufbt:nano /etc/fstab {{{ # # Use 'vol_id --uuid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # proc /proc proc defaults 0 0 # / was on /dev/sda1 during installation UUID=26ec2fb6-a3b8-4ed0-843f-8e66ca2a974d / ext4 relatime,errors=remount-ro 0 1 # none was on /dev/sda5 during installation UUID=d4d1875d-8c1e-469f-990f-7a2967659c1d none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 ##New Drives /dev/sdb1 /mnt/ext3 ext3 user 0 2 /dev/sdb2 /mnt/ntfs ntfs-3g auto,users,uid=1001,gid=100,utf8,dmask=027,fmask=1 37 0 0 /dev/sdb5 /mnt/fat32 vfat auto,users,uid=1001,gid=100,utf8,dmask=027,fmask=1 37 0 0 }}} root@ufbt:mount -a root@ufbt:df -h {{{ Filesystem Size Used Avail Use% Mounted on /dev/sda1 5.7G 2.4G 3.0G 45% / tmpfs 245M 0 245M 0% /lib/init/rw varrun 245M 96K 245M 1% /var/run varlock 245M 0 245M 0% /var/lock udev 245M 60K 245M 1% /dev tmpfs 245M 0 245M 0% /dev/shm lrm 245M 2.4M 243M 1% /lib/modules/2.6.28-4-generic/volatile /dev/sdb1 1.6G 35M 1.4G 3% /mnt/ext3 /dev/sdb2 1.6G 8.4M 1.6G 1% /mnt/ntfs /dev/sdb5 2.0G 4.0K 2.0G 1% /mnt/fat32 }}} root@ufbt:mkdir /mnt/ext3/temp root@ufbt:ls -al /mnt/ext3/temp/ {{{ total 8 drwxr-xr-x 2 root root 4096 2009-01-27 12:13 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} root@ufbt:chown guru /mnt/ext3/temp/ root@ufbt:ls -al /mnt/ext3/temp/ {{{ total 8 drwxr-xr-x 2 guru root 4096 2009-01-27 12:13 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} root@ufbt:chown guru:guru /mnt/ext3/temp/ root@ufbt:ls -al /mnt/ext3/temp/ {{{ total 8 drwxr-xr-x 2 guru guru 4096 2009-01-27 12:14 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} root@ufbt:chown root.root /mnt/ext3/temp/ root@ufbt:ls -al /mnt/ext3/temp/ {{{ total 8 drwxr-xr-x 2 root root 4096 2009-01-27 12:14 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} root@ufbt:chmod 664 /mnt/ext3/temp/ root@ufbt:ls -al /mnt/ext3/temp {{{ total 8 drw-rw-r-- 2 root root 4096 2009-01-27 12:15 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} root@ufbt:chmod 600 /mnt/ext3/temp/ root@ufbt:ls -al /mnt/ext3/temp/ {{{ total 8 drw------- 2 root root 4096 2009-01-27 12:16 drwxr-xr-x 4 root root 4096 2009-01-27 12:13 }}} ---- CategoryBeginnersTeam