Red Hat This forum is for the discussion of Red Hat Linux. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-13-2013, 06:15 PM
|
#1
|
Member
Registered: Jun 2012
Posts: 264
Rep:
|
Mounting a bootable USB stick makes the stick non-bootable
I have a process used to create bootable CentOS 6.3 installer sticks. I use a command similar to
dd if=myimage.img of=/dev/sdx bs=16k
to burn my custom image onto a USB stick, and from here I can boot my systems with one of these systems to perform the OS install.
I've hit a problem which I've never seen before that I cannot understand. After burning a USB stick, I sometimes mount it and copy additional files to it (for example for debugging purposes). So I might do this:
dd if=myimage.img of=/dev/sdx bs=16k
partx -av /dev/sdx
mount /dev/sdx1 /mnt
cp myfile.dat /mnt
umount /mnt
partx -dv /dev/sdx
After doing this, for some reason the stick is no longer bootable. The system comes up with the error "No operating system", which of course is the error you typically see when booting with a disk that had a partition flagged as bootable but there is no OS present on the disk. The OS *is* there though, so the error doesn't make sense.
What's more confusing though is all I have to do is just mount the disk--I don't even have to copy anything to it. Just the acting of burning an image to the disk and then mounting it causes it to be not bootable. Even if I mount the disk read-only, it will longer boot.
I have another bootable image created by the same process and this problem does not occur with that image. I can repeat these same steps and the stick boots fine afterwards.
So I'm stuck with this. Does anyone have any idea what's going on?
|
|
|
03-14-2013, 06:33 PM
|
#2
|
LQ Guru
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
|
I have seen weird errors like yours without ever getting to an explanation. If you try the same process on a different USB stick (just another one, doesn't even have to be different) does it happen as well?
If that other one is correct, trash the problematic stick. Unless you want to research it for academic reasons. Highly unsatisfactory of course.
jlinkels
|
|
|
03-14-2013, 07:32 PM
|
#3
|
Moderator
Registered: Mar 2008
Posts: 22,129
|
I don't get the partx reason. (OK, don't know why you do partx)
The dd command from file to device should have been part of the original image. It shouldn't need any more partition issues unless you are trying to fill it??
Why don't you just mount or automount the usb and make changes?
Not sure I'd even use bs= either. I'm on the fence on that.
Last edited by jefro; 03-14-2013 at 07:35 PM.
|
|
|
03-14-2013, 07:59 PM
|
#4
|
Senior Member
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,792
|
You could do the simple "mount and unmount", and then compare the data on the drive with the original image (not the contents of the files, but a byte-by-byte compare of the image). I suspect it's some variant of what happens when the boot files get moved without re-installing the boot loader. Everything appears to work just fine, but the boot loader is actually using the data from the old physical locations, blocks that are now marked as "free" in the file system. Then you make some unrelated change, those free blocks get used for something else, and your system won't boot any more.
What's the file system inside that image? SWAG here: If it's ext3 or ext4, then it could be the journal that is overwriting the blocks that the boot loader is using.
|
|
|
03-15-2013, 10:12 AM
|
#5
|
Member
Registered: Jun 2012
Posts: 264
Original Poster
Rep:
|
I resolved the problem, although I don't have a good explanation for the solution. I decided to reboot the system where I was generating my image and then created a new image. After doing this, the problem went away. I can now burn this image onto a USB stick, mount/umount the USB stick, and the USB still boots. It always used to work so I knew there was something wonky going on, but this definitely is *very* wonky.
Unfortunately I lost a day of my life before deciding to reboot the system.
'Nuff said...
|
|
|
03-15-2013, 10:34 AM
|
#6
|
Moderator
Registered: Mar 2008
Posts: 22,129
|
Thanks for the update.
|
|
|
03-15-2013, 01:44 PM
|
#7
|
Member
Registered: Aug 2009
Location: Umzinto, South Africa
Distribution: Crunchbangified Debian 8 (Jessie)
Posts: 747
Rep:
|
Quote:
Originally Posted by PeterSteele
Unfortunately I lost a day of my life before deciding to reboot the system.
'Nuff said...
|
Then you probably wont find this clip as funny as I did!
The IT Crowd - Have you tried turning it off and on again?
|
|
|
All times are GMT -5. The time now is 05:50 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|