{"id":389,"date":"2009-09-03T18:15:00","date_gmt":"2009-09-04T01:15:00","guid":{"rendered":"https:\/\/kb.terabyteunlimited.com\/kb-articles\/modifying-linux-boot-files-using-dev-disk-by-id-when-restoring-to-a-different-system-or-physical-drive\/"},"modified":"2021-09-07T15:04:44","modified_gmt":"2021-09-07T22:04:44","slug":"modifying-linux-boot-files-using-dev-disk-by-id-when-restoring-to-a-different-system-or-physical-drive","status":"publish","type":"lsvr_kba","link":"https:\/\/www.terabyteunlimited.com\/kb\/kb-articles\/modifying-linux-boot-files-using-dev-disk-by-id-when-restoring-to-a-different-system-or-physical-drive\/","title":{"rendered":"Modifying Linux Boot Files Using \/dev\/disk\/by-id When Restoring To a Different System or Physical Drive"},"content":{"rendered":"<p>Some Linux distributions (most notably OpenSUSE) will set up the <strong>fstab<\/strong> (\/etc\/fstab) and <strong>menu.lst<\/strong> (\/boot\/grub\/menu.lst) files using the \/dev\/disk\/by-id method of identifying partitions. While this normally will work OK, problems can be encountered when an image of the Linux installation is created and then restored to a different drive or system. The restored image will fail to boot, typically with an error message related to \/dev\/disk\/by-id.<\/p>\r\n  <p>To overcome this situation, all lines referencing partitions using the &quot;by-id&quot; method in fstab and menu.lst should be changed so that they are using the UUID method of identifying each partition. The UUID of a partition (for both regular and swap partitions) is created when the partition is formatted, and will always remain valid, regardless of what system or drive the partition is located on. <br \/><\/p>\r\n  <p>&nbsp;<\/p>\r\n  <p><strong>An example of changing an fstab file to use UUIDs:<\/strong> <\/p>\r\n  <p>The lines below are from an <strong>fstab<\/strong> file originally set up using \/dev\/disk\/by-id. The first line is for the swap partition, and the second line for the root partition:<br \/><\/p>\r\n  <p><font size=\"1\"><strong>\/dev\/disk\/by-id\/scsi-3600605b000db099011b1713421c457ad-part1 swap swap&nbsp; defaults &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0<\/strong><\/font><br \/><font size=\"1\">\/<\/font><font size=\"1\"><strong>dev\/disk\/by-id\/scsi-3600605b000db099011b1713421c457ad-part2 \/&nbsp;&nbsp;&nbsp; ext3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acl,user_xattr&nbsp; 1 1<\/strong><\/font><\/p>\r\n  <p>To convert these lines to use UUIDs, the UUIDs of both partitions must be determined. The command <strong>'blkid'<\/strong> can be used for this purpose. This command will list all UUIDs for all partitions on a system. The 'blkid' command is included with the e2fsprogs set of utilities, and will be available on all distributions. The 'blkid' command is also available on the IFL boot disk.<\/p>\r\n  <p>Once the actual UUIDs are determined for the partitions, the 2 lines above can be changed as shown below: <br \/><\/p>\r\n  <p><font size=\"1\"><strong>UUID=b8484bab-ea06-48a9-96ce-ef9b5a7def34&nbsp;&nbsp; swap&nbsp;&nbsp;&nbsp; swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defaults&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0 0<br \/>UUID=b13e754d-80d8-431d-a24e-54445693efcb&nbsp; \/&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ext3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acl,user_xattr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 1 <\/strong><\/font><br \/><\/p>\r\n  <p>&nbsp;<\/p>\r\n  <p><strong>An example of changing a menu.lst file (stanza) to use UUIDs:<\/strong><\/p>\r\n  <p>Similar changes are required for the <strong>menu.lst<\/strong> file. A typical menu.lst file will contain one or more boot stanzas. Each stanza will have to be reviewed for instances of using \/dev\/disk\/by-id, and each instance of &quot;by-id&quot; will need to be changed to use UUIDs instead.<br \/><\/p>\r\n  <p>An example of a menu.lst boot stanza using the &quot;by-id&quot;&nbsp; method is shown below:<\/p>\r\n  <p><font size=\"1\"><strong>title openSUSE 11.1 - 2.6.27.21-0.1<br \/>&nbsp;&nbsp;&nbsp; root (hd0,1)<br \/>&nbsp;&nbsp;&nbsp; kernel \/boot\/vmlinuz-2.6.27.21-0.1-default <br \/>&nbsp;&nbsp;&nbsp; root=\/dev\/disk\/by-id\/scsi-3600605b000db099011b1713421c457ad-part2<br \/>&nbsp;&nbsp;&nbsp; resume=\/dev\/disk\/by-id\/scsi-3600605b000db099011b1713421c457ad-part1 splash=silent <br \/>&nbsp;&nbsp;&nbsp; showopts vga=0x31a<br \/>&nbsp;&nbsp;&nbsp; initrd \/boot\/initrd-2.6.27.21-0.1-default<\/strong><\/font><br \/><\/p>\r\n  <p>Note that the &quot;kernel&quot; line above is actually wrapped 3 times to fit on the screen, so the 3 lines following it are all actually part of the kernel line. The stanza above converted to use UUIDs will look as shown below:<\/p>\r\n  <p><font size=\"1\"><strong>title openSUSE 11.1 - 2.6.27.21-0.1<br \/>&nbsp;&nbsp;&nbsp; uuid&nbsp;&nbsp; b13e754d-80d8-431d-a24e-54445693efcb<br \/>&nbsp;&nbsp;&nbsp; kernel \/boot\/vmlinuz-2.6.27.21-0.1-default<br \/>&nbsp;&nbsp;&nbsp; root=UUID=b13e754d-80d8-431d-a24e-54445693efcb<br \/>&nbsp;&nbsp;&nbsp; resume=UUID=b8484bab-ea06-48a9-96ce-ef9b5a7def34 splash=silent<br \/>&nbsp;&nbsp;&nbsp; showopts vga=0x31a<br \/>&nbsp;&nbsp;&nbsp; initrd \/boot\/initrd-2.6.27.21-0.1-default<\/strong><\/font><br \/><\/p>\r\n  <p>The &quot;resume=&quot; value is referring to the swap partition, so the UUID for the swap partition must be used for that value. Note that in addition to changing the &quot;by-id&quot; references to UUIDs, the <strong>root (hd0,1)<\/strong> line was also changed to <strong>uuid &lt;UUID&gt;<\/strong>. This allows Grub to find the Grub root partition based on its UUID, regardless of what it's actual drive\/partition location is.<\/p>\r\n  <p>When editing the fstab and menu.lst files, it is suggested that you make backup copies of the original files before making any changes.<\/p>\r\n  <p><br \/><\/p>","protected":false},"excerpt":{"rendered":"<p>Some Linux distributions (most notably OpenSUSE) will set up the fstab (\/etc\/fstab) and menu.lst (\/boot\/grub\/menu.lst) files using the \/dev\/disk\/by-id method of identifying partitions. While this normally will work OK, problems can be encountered when an image of the Linux installation is created and then restored to a different drive or system. The restored image will [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"lsvr_kba_cat":[1816],"lsvr_kba_tag":[2123],"class_list":["post-389","lsvr_kba","type-lsvr_kba","status-publish","hentry","lsvr_kba_cat-problem-solving-image-for-linux","lsvr_kba_tag-image-for-linux"],"_links":{"self":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba"}],"about":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/types\/lsvr_kba"}],"author":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/comments?post=389"}],"version-history":[{"count":1,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/389\/revisions"}],"predecessor-version":[{"id":6341,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba\/389\/revisions\/6341"}],"wp:attachment":[{"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/media?parent=389"}],"wp:term":[{"taxonomy":"lsvr_kba_cat","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_cat?post=389"},{"taxonomy":"lsvr_kba_tag","embeddable":true,"href":"https:\/\/www.terabyteunlimited.com\/kb\/wp-json\/wp\/v2\/lsvr_kba_tag?post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}