{"id":373,"date":"2011-03-10T19:48:30","date_gmt":"2011-03-10T19:48:30","guid":{"rendered":"http:\/\/cdblog.cdstealer.com\/?p=373"},"modified":"2016-06-04T16:21:38","modified_gmt":"2016-06-04T15:21:38","slug":"remotely-repartition-the-hdd","status":"publish","type":"post","link":"https:\/\/cdblog.cdstealer.com\/?p=373","title":{"rendered":"Remotely repartition the HDD."},"content":{"rendered":"<p>Have you or do you know someone that has performed a reinstall of an OS and left the partition options at the default ie everything under \/ and omitted setting up the partitions?<br \/>\nAll is not lost.. this guide was performed on a RHEL 5.5 install and worked flawlessly. :)<\/p>\n<p>In a nutshell, we're dumping the filesystem on to the swap partition, repartitioning the drive and then dumping the data back into the respective partitions.\u00a0 The pitfall in this is your swap partition <strong>HAS<\/strong> to be large enough to store your data.\u00a0 Are we sitting comfortably?... then I'll begin.<\/p>\n<p>execute <strong>lvdisplay<\/strong> to get LogVol01 size, then do a <strong>df -h<\/strong> and see if \/ will fit on swap.<\/p>\n<p><strong><span style=\"color: #ff0000;\">Copy the FS to SWAP.<\/span><\/strong><br \/>\n1) Edit <strong>\/boot\/grub\/grub.conf<\/strong><br \/>\nchange root=\/dev\/VolGroup00\/LogVol00 to root=\/dev\/VolGroup00\/<strong>LogVol01<\/strong> (the default swap partition)<br \/>\n2) Edit \/etc\/fstab<br \/>\ncomment \/dev\/VolGroup00\/LogVol00 and change LogVol01 to \/ ext3 (swap becomes the new root)<br \/>\n3) run swapoff -a<br \/>\n4) mkfs -t ext3 -m 1 -v \/dev\/VolGroup00\/LogVol01 (format the swap partition)<br \/>\n5) mount \/dev\/VolGroup00\/LogVol01 \/mnt<br \/>\n6) tar clf - -C \/ .| tar xf - -C \/mnt (this is better than cp as it keeps the file attributes)<\/p>\n<pre>clf -     create, sym links, file \r\n-C \/   \u00a0 \u00a0Change directory to \/ &lt;source&gt;\r\n.|        pass everything to \r\nxf -      extract, file\r\n-C \/mnt   Change directory to \/mnt &lt;destination&gt;<\/pre>\n<p><span style=\"color: #00ff00;\"><strong>REBOOT<\/strong><\/span><br \/>\n(execute a <strong>df -h<\/strong> and check the size of \/, it should be the size of swap previous)<\/p>\n<p><span style=\"color: #ff0000;\"><strong>Create the new partitions.<\/strong><\/span><br \/>\n7) lvremove \/dev\/VolGroup00\/LogVol00 (this completely deletes the \/ partition)<br \/>\n8) lvcreate -L30G -n rootvol VolGroup00 (this creates a 30G partition named rootvol)<br \/>\n9) lvcreate -L30G -n usrlocalvol VolGroup00<br \/>\n10) lvcreate -L4G -n varvol VolGroup00<br \/>\n11) lvcreate -L4G -n optvol VolGroup00<br \/>\n12) mkfs -t ext3 -m 1 -v \/dev\/VolGroup00\/rootvol (format the new partitions)<br \/>\n13) mkfs -t ext3 -m 1 -v \/dev\/VolGroup00\/usrlocalvol<br \/>\n14) mkfs -t ext3 -m 1 -v \/dev\/VolGroup00\/varvol<br \/>\n15) mkfs -t ext3 -m 1 -v \/dev\/VolGroup00\/optvol<br \/>\n16) vi \/etc\/fstab and add the new partitions: (make the partitions available)<\/p>\n<pre><span style=\"color: #0000ff;\">\/dev\/VolGroup00\/rootvol \u00a0 \u00a0 \u00a0  \/ \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 ext3 \u00a0 \u00a0defaults \u00a0 1 1\r\n\/dev\/VolGroup00\/usrlocalvol \u00a0 \u00a0\/usr\/local \u00a0 \u00a0 \u00a0ext3 \u00a0 \u00a0defaults \u00a0\u00a01 1\r\n\/dev\/VolGroup00\/varvol \u00a0 \u00a0 \u00a0 \u00a0 \/var \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0ext3 \u00a0 \u00a0defaults \u00a0\u00a01 1\r\n\/dev\/VolGroup00\/optvol \u00a0 \u00a0 \u00a0 \u00a0\u00a0\/opt \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0ext3 \u00a0 \u00a0defaults \u00a0 1 1\r\n<\/span><\/pre>\n<p><span style=\"color: #ff0000;\"><strong>Now to restore the data:<\/strong><\/span><br \/>\n17) mkdir \/media\/root \/media\/var \/media\/opt \/media\/usr<br \/>\n18) mount \/dev\/VolGroup00\/rootvol \/media\/root<br \/>\n19) mount \/dev\/VolGroup00\/usrlocalvol \/media\/usr<br \/>\n20) mount \/dev\/VolGroup00\/varvol \/media\/var<br \/>\n21) mount \/dev\/VolGroup00\/optvol \/media\/opt<br \/>\n22) tar clf - -C \/ .| tar xf - -C \/media\/root<br \/>\n23) tar clf - -C \/var\/ .| tar xf - -C \/media\/var<br \/>\n24) tar clf - -C \/opt\/ .| tar xf - -C \/media\/opt<br \/>\n25) tar clf - -C \/usr\/local\/ .| tar xf - -C \/media\/usr<br \/>\n26) edit \/media\/root\/etc\/fstab (ensure new mounts are present &amp; comment<br \/>\nLogVol01)<br \/>\n27) edit \/boot\/grub\/grub.conf<br \/>\nchange root=\/dev\/VolGroup00\/LogVol01 to root=\/dev\/VolGroup00\/rootvol<br \/>\n28) rm -rf \/media\/root\/usr\/local\/* \/media\/root\/var\/* \/media\/root\/opt\/*<\/p>\n<p><span style=\"color: #00ff00;\"><strong>REBOOT<\/strong><\/span><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Reactivate the swap partition<\/strong><\/span><br \/>\n29) lvremove \/dev\/VolGroup00\/LogVol01<br \/>\n30) lvcreate -L16G -n swapvol VolGroup00<br \/>\n31) mkswap \/dev\/VolGroup00\/swapvol<br \/>\n32) Edit \/etc\/fstab<br \/>\nchange LogVol01 \/ ext3 to swapvol swap swap<br \/>\n33) swapon \/dev\/VolGroup00\/swapvol<\/p>\n<p><span style=\"color: #00ff00;\"><strong>REBOOT<\/strong><\/span><\/p>\n<p>Congratulations.. your server is now in a sensible condition.\u00a0 Sit back, relax and give yourself a pat on the back for not looking like a complete n00b!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Have you or do you know someone that has performed a reinstall of an OS and left the partition options at the default ie everything under \/ and omitted setting up the partitions? All is not lost.. this guide was performed on a RHEL 5.5 install and worked flawlessly. :) In a nutshell, we're dumping &hellip; <a href=\"https:\/\/cdblog.cdstealer.com\/?p=373\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Remotely repartition the HDD.<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[18,65,64,63],"class_list":["post-373","post","type-post","status-publish","format-standard","hentry","category-gentoo","tag-linux","tag-lvm","tag-partition","tag-redhat"],"_links":{"self":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=373"}],"version-history":[{"count":11,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions"}],"predecessor-version":[{"id":1186,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=\/wp\/v2\/posts\/373\/revisions\/1186"}],"wp:attachment":[{"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cdblog.cdstealer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}