{"id":1092,"date":"2009-01-10T22:23:31","date_gmt":"2009-01-11T05:23:31","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/2009\/01\/10\/preparing-your-primary-mount-and-swap-with-fdisk\/"},"modified":"2009-01-10T22:23:31","modified_gmt":"2009-01-11T05:23:31","slug":"preparing-your-primary-mount-and-swap-with-fdisk","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/preparing-your-primary-mount-and-swap-with-fdisk\/","title":{"rendered":"Preparing your primary mount and swap with fdisk"},"content":{"rendered":"<p>I have 4 big drives on a new machine, each can  hold up to 2Tb of data, at first I thought I&#8217;d use the first drive for the OS and the other 3 for a RAID5 (software controlled)<\/p>\n<p>Then after I had installed the operating system, I decided it was a big waste, and that I&#8217;d only need about 80gigs for the OS, and that I should use the 1920Gb (-swap,-other blocks) to be part of the RAID.<\/p>\n<p>The first thing I needed to do was to resize the primary partition, but you can&#8217;t really do this while you&#8217;re using it. So I restarted with the Ubuntu CD in rescue mode, and jumped to the part where you setup the partition sizes. I told it I wanted to make the first partition smaller, I made it 80Gb, I accepted the rest of the options, and after a long while, it was finished creating the file systems, but it seems like it did a mess.<\/p>\n<p>I restarted without the CD, crossed my fingers, and it did boot.<\/p>\n<p>I did a:<\/p>\n<pre>sudo fdisk -l\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *          63   156264254    78132096   83  Linux\n\/dev\/sda2       156264255  2930272064  1387003905    5  Extended\n\/dev\/sda5      2882334168  2930272064    23968948+  82  Linux swap \/ Solaris\n\/dev\/sda6       156264381  2834380079  1339057849+  83  Linux\n\/dev\/sda7      2834380143  2882334104    23976981   82  Linux swap \/ Solaris\n<\/pre>\n<p>and there were 6 partitions, some overlapping, but the primary looked right. I entered fdisk and deleted the 5 other partitions, and started a new.<\/p>\n<p>Created a new partition (2) for Swap. Since the machine has 8GB of Ram, that&#8217;s the amount of Swap I used for it. After the partition was defined, I changed it&#8217;s type to type 82 (Linux Swap)<\/p>\n<p>Then I created another partition (3), this one using the remaining space, and set it&#8217;s type to 83 (Linux)<\/p>\n<p>I wrote the changes (w) and exited. It told me that the changes were written but the partitions would not be used until I rebooted, so I rebooted.<\/p>\n<p>When I came back and did:<\/p>\n<pre>sudo fdisk -l<\/pre>\n<p>There they were:<\/p>\n<pre>\n   Device Boot      Start         End      Blocks   Id  System\n\/dev\/sda1   *           1        9727    78132096   83  Linux\n\/dev\/sda2            9728       10700     7812500+  82  Linux swap \/ Solaris\n\/dev\/sda3           10700      182402  1379193956   83  Linux\n<\/pre>\n<p>But now there was a problem, when I checked for the memory available there was no swap<\/p>\n<pre>\n$ free\n             total       used       free     shared    buffers     cached\nMem:       8183920     198524    7985396          0       6668      70284\n-\/+ buffers\/cache:     121572    8062348\nSwap:            0          0          0\n<\/pre>\n<p>So, first thing, I made sure the swap was specified on \/etc\/fstab for the next boot to include the swap<\/p>\n<pre>\/dev\/sda2 none swap sw 0 0<\/pre>\n<p>And then I had to make a file system for the swap<\/p>\n<pre>sudo mkswap \/dev\/sda2<\/pre>\n<p>Then, the &#8220;free&#8221; command did show the swap:<\/p>\n<pre>$ free\n             total       used       free     shared    buffers     cached\nMem:       8183920     220420    7963500          0       7552      86880\n-\/+ buffers\/cache:     125988    8057932\nSwap:      7812492          0    7812492\n<\/pre>\n<p>In this case I didn&#8217;t have to make the file system for the primary partition because it was already made, I suppose the term &#8220;making the file system&#8221; is the equivalent of saying &#8220;formatting the drive with a specific filesystem&#8221;<\/p>\n<p>However I had to do it for the remainder of the disk:<\/p>\n<pre>sudo mkfs.ext3 \/dev\/sda3<\/pre>\n<p>I&#8217;ll let you know if I find anything different from the tutorials on <a href=\"http:\/\/beginlinux.com\/server_training\/server-managment-topics\/998-create-raid-on-ubuntu-804-part-1\">how to make RAID5<\/a>.<\/p>\n<p><strong>New \/etc\/fstab format in Ubuntu<\/strong><br \/>\nI while later, I updated the \/etc\/fstab to include the UUID of the swap partition on the fstab, instead of the device name.<br \/>\nTo obtain this UUID I learned about the vol_id command<\/p>\n<pre>$ sudo vol_id \/dev\/sda2\nID_FS_USAGE=other\nID_FS_TYPE=swap\nID_FS_VERSION=2\nID_FS_UUID=<strong>b9b825c2-85dc-4def-bfd1-9071042452fa<\/strong>\nID_FS_UUID_ENC=b9b825c2-85dc-4def-bfd1-9071042452fa\nID_FS_LABEL=\nID_FS_LABEL_ENC=\nID_FS_LABEL_SAFE=<\/pre>\n<p>Now my \/etc\/fstab file looks like this:<\/p>\n<pre>\n# \/etc\/fstab: static file system information.                                                                                          \n#                                                                                                                                      \n# <file system> <mount point>   <type>  <options>       <dump>  <pass>                                                                 \nproc            \/proc           proc    defaults        0       0\n# \/dev\/sda1                                                                                                                            \nUUID=13676a4b-b669-4a7a-9776-cb10c7b492b9 \/               ext3    relatime,errors=remount-ro 0       1\n<strong>#\/dev\/sda2                                                                                                                             \nUUID=b9b825c2-85dc-4def-bfd1-9071042452fa none swap sw 0 0\n<\/strong>\/dev\/scd0       \/media\/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have 4 big drives on a new machine, each can hold up to 2Tb of data, at first I thought I&#8217;d use the first drive for the OS and the other 3 for a RAID5 (software controlled) Then after I had installed the operating system, I decided it was a big waste, and that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[30],"tags":[384,395,412,433,440,511,513,514,515,518,1449,675,802,954],"class_list":["post-1092","post","type-post","status-publish","format-standard","hentry","category-geeklife","tag-ext3","tag-fdisk","tag-filesystem","tag-format","tag-free","tag-hard","tag-hard-disk","tag-hard-drive","tag-harddrive","tag-hdd","tag-linux","tag-mkfs","tag-primary","tag-swap"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-hC","jetpack-related-posts":[{"id":3127,"url":"https:\/\/www.gubatron.com\/blog\/cant-ssh-to-ec2-ubuntu-instance-etcfstab-breaks-bootup-due-to-missing-ebs-volume-solved\/","url_meta":{"origin":1092,"position":0},"title":"can&#8217;t ssh to ec2 ubuntu instance, \/etc\/fstab breaks bootup due to missing ebs volume [SOLVED]","author":"gubatron","date":"August 21, 2013","format":false,"excerpt":"So the \/etc\/fstab file on your root volume looked like this LABEL=cloudimg-rootfs \/ ext4 defaults 0 0 \/dev\/xvdf \/mnt\/backups auto defaults,comment=cloudconfig 0 2 by mistake you deleted the ebs volume that you had mounted on \/mnt\/backups (or whatever folder) and you restarted your ubuntu instance not knowing that if the\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3977,"url":"https:\/\/www.gubatron.com\/blog\/how-to-resize-aws-ec2-ebs-root-partition-without-rebooting-in-3-steps\/","url_meta":{"origin":1092,"position":1},"title":"How to resize AWS ec2 ebs root partition without rebooting in 3 steps","author":"gubatron","date":"September 14, 2022","format":false,"excerpt":"Go to the AWS EBS dashboard and modify the volume size. Might be good to create a snapshot of it for safety but haven't really failed ever doing this. # 1. Check the device of your partition $ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/09\/xai-tmp-imgen-db8aab31-34e5-4be7-b882-a7e87a2836f9.jpg?fit=1091%2C655&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/09\/xai-tmp-imgen-db8aab31-34e5-4be7-b882-a7e87a2836f9.jpg?fit=1091%2C655&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/09\/xai-tmp-imgen-db8aab31-34e5-4be7-b882-a7e87a2836f9.jpg?fit=1091%2C655&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/09\/xai-tmp-imgen-db8aab31-34e5-4be7-b882-a7e87a2836f9.jpg?fit=1091%2C655&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/09\/xai-tmp-imgen-db8aab31-34e5-4be7-b882-a7e87a2836f9.jpg?fit=1091%2C655&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3370,"url":"https:\/\/www.gubatron.com\/blog\/how-to-resize-an-ebs-xfs-formatted-partition\/","url_meta":{"origin":1092,"position":2},"title":"How to resize an EBS (xfs formatted) partition","author":"gubatron","date":"December 20, 2014","format":false,"excerpt":"First of all, create a snapshot of your EBS volume. Then out of that snapshot you will be able to create your new volume. However, when you detach the old one from your instance and attach the new one, you will still see the old available space with df look\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/12\/Screen-Shot-2016-01-02-at-4.42.45-PM.png?fit=1200%2C420&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/12\/Screen-Shot-2016-01-02-at-4.42.45-PM.png?fit=1200%2C420&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/12\/Screen-Shot-2016-01-02-at-4.42.45-PM.png?fit=1200%2C420&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/12\/Screen-Shot-2016-01-02-at-4.42.45-PM.png?fit=1200%2C420&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2014\/12\/Screen-Shot-2016-01-02-at-4.42.45-PM.png?fit=1200%2C420&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3,"url":"https:\/\/www.gubatron.com\/blog\/javascript-quicksort-implementation-with-dynamic-comparator\/","url_meta":{"origin":1092,"position":3},"title":"Javascript Quicksort implementation with dynamic comparator.","author":"gubatron","date":"February 29, 2012","format":false,"excerpt":"[javascript] Array.prototype.swap=function(a, b) { var tmp=this[a]; this[a]=this[b]; this[b]=tmp; } function quickSort(array,comparator) { qsort(array,0,array.length,comparator); } \/** * NOTE: the comparator is a dynamic function you will define like so comparator(a,b) { if (a > b) return 1; else if (a < b) return -1; else { return 0; } } *\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2247,"url":"https:\/\/www.gubatron.com\/blog\/how-to-resize-a-virtualbox-vdi-fixed-size-virtual-drive-on-mac\/","url_meta":{"origin":1092,"position":4},"title":"How to resize a VirtualBox fixed size virtual drive (.vdi) on Mac","author":"gubatron","date":"August 29, 2011","format":false,"excerpt":"So you created a disk for your Windows or Linux VirtualBox VM and you made the mistake of not creating the drive as a dynamically expanding storage drive, you chose fixed size. Now you're running out of space and all your Google searches point you to stupid posts on the\u2026","rel":"","context":"In &quot;Geeklife&quot;","block_context":{"text":"Geeklife","link":"https:\/\/www.gubatron.com\/blog\/category\/geeklife\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":115,"url":"https:\/\/www.gubatron.com\/blog\/happy-in-the-snow\/","url_meta":{"origin":1092,"position":5},"title":"Happy in the Snow","author":"gubatron","date":"March 3, 2005","format":false,"excerpt":"Let's make this post in english for a change. My street I often say its a pain in the neck to be putting up with all this cold and have no snow around, I mean, If I'm gonna be cold, at least give me a visual reason to understand why\u2026","rel":"","context":"In &quot;Gubatron&quot;","block_context":{"text":"Gubatron","link":"https:\/\/www.gubatron.com\/blog\/category\/gubatron\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1092","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=1092"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/1092\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=1092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=1092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=1092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}