I just carelessly overwrote my /etc/fstab file with the following: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee /etc/fstab .. when I meant: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee -a /etc/fstab (-a means append)
Any suggestions for recovery?
This is a fresh install of Ubuntu 8.04 Server, so worst case I will have to reinstall the O/S but I'd like to recover if possible, not least so I know how to do it next time I am silly!
[Feeling very foolish right now...]
Hi,
2008/5/12 Mark Rogers mark@quarella.co.uk:
I just carelessly overwrote my /etc/fstab file with the following: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee /etc/fstab .. when I meant: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee -a /etc/fstab (-a means append)
To append, I usually use cat "foobar" >> /file/to/append/to No use of tee :)
Any suggestions for recovery?
Can you not just recreate it by hand?
- Srdj
Srdjan Todorovic wrote:
To append, I usually use cat "foobar" >> /file/to/append/to No use of tee :
Sadly that won't work if /file/to/append/to requires root permissions to write to it (and assuming you're not logged in as root).
sudo cat "foobar" >> /file/to/append/to .. would execute the cat command as root (unnecessary) and drop back to normal user privileges to write the output to the file (which won't work).
That said, it's as easy to > instead of >> as it is to "tee" instead of "tee -a" :-)
On Mon, 12 May 2008 12:13:18 +0100 Mark Rogers mark@quarella.co.uk allegedly wrote:
That said, it's as easy to > instead of >> as it is to "tee" instead of "tee -a" :-)
sudo vi file-to-edit works for me :-)
Mick
(Please no emacs flames) ---------------------------------------------------------------------
This is a Microsoft free zone. Please do not send me Microsoft Word Documents. For some reasons, see:
www.gnu.org/philosophy/no-word-attachments.html www.goldmark.org/netrants/no-word/attach.html ---------------------------------------------------------------------
mbm wrote:
sudo vi file-to-edit works for me :-)
I was trying to write up some instructions for our internal wiki, and where possible I try to make them as copy+pastable as possible. Writing instructions to make changes to key system files ought to be less reliable that writing good script-like instructions, but of-course that only works if the writer doesn't make basic errors themselves...
On 12 May 10:34, Mark Rogers wrote:
I just carelessly overwrote my /etc/fstab file with the following: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee /etc/fstab .. when I meant: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee -a /etc/fstab (-a means append)
Any suggestions for recovery?
This is a fresh install of Ubuntu 8.04 Server, so worst case I will have to reinstall the O/S but I'd like to recover if possible, not least so I know how to do it next time I am silly!
[Feeling very foolish right now...]
Well, assuming that you haven't unmounted anything, you should be able to get enough info from the output of /proc/mounts to rebuild your /etc/fstab...
(infact, there's every possibility that you can remove a few things from there... like the tmpfs mounts, and probably /dev, which will be done automatically by udev anyways.)
Hope that helps...
Brett Parker wrote:
Well, assuming that you haven't unmounted anything, you should be able to get enough info from the output of /proc/mounts to rebuild your /etc/fstab...
(infact, there's every possibility that you can remove a few things from there... like the tmpfs mounts, and probably /dev, which will be done automatically by udev anyways.)
In the good old days I understood fstab, but now with UUIDs etc I'm a bit out of date.
I haven't unmounted anything so I have all the information I need, if only I can work out how to use it. What I have to work from is:
$cat /proc/mounts rootfs / rootfs rw 0 0 none /sys sysfs rw,nosuid,nodev,noexec 0 0 none /proc proc rw,nosuid,nodev,noexec 0 0 udev /dev tmpfs rw,relatime 0 0 fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 /dev/disk/by-uuid/c753a899-0637-4963-9f77-a825051bb917 / ext3 rw,relatime,errors=remount-ro,data=ordered 0 0 /dev/disk/by-uuid/c753a899-0637-4963-9f77-a825051bb917 /dev/.static/dev ext3 rw,relatime,errors=remount-ro,data=ordered 0 0 tmpfs /var/run tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /dev/shm tmpfs rw,relatime 0 0 devpts /dev/pts devpts rw,relatime 0 0 tmpfs /var/run tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0 securityfs /sys/kernel/security securityfs rw,relatime 0 0
Does something like this look reasonable? (I can't think of a way to test safely) proc /proc proc defaults 0 0 UUID=c753a899-0637-4963-9f77-a825051bb917 / ext3 defaults,errors=remount-ro 0 1
It looks a bit sparse, to say the least! Should I have something in there for swap and CD (neither of which are in the mount output)?
On 12 May 12:27, Mark Rogers wrote:
Brett Parker wrote:
Well, assuming that you haven't unmounted anything, you should be able to get enough info from the output of /proc/mounts to rebuild your /etc/fstab...
(infact, there's every possibility that you can remove a few things from there... like the tmpfs mounts, and probably /dev, which will be done automatically by udev anyways.)
In the good old days I understood fstab, but now with UUIDs etc I'm a bit out of date.
I haven't unmounted anything so I have all the information I need, if only I can work out how to use it. What I have to work from is:
$cat /proc/mounts rootfs / rootfs rw 0 0 none /sys sysfs rw,nosuid,nodev,noexec 0 0 none /proc proc rw,nosuid,nodev,noexec 0 0 udev /dev tmpfs rw,relatime 0 0 fusectl /sys/fs/fuse/connections fusectl rw,relatime 0 0 /dev/disk/by-uuid/c753a899-0637-4963-9f77-a825051bb917 / ext3 rw,relatime,errors=remount-ro,data=ordered 0 0 /dev/disk/by-uuid/c753a899-0637-4963-9f77-a825051bb917 /dev/.static/dev ext3 rw,relatime,errors=remount-ro,data=ordered 0 0 tmpfs /var/run tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /dev/shm tmpfs rw,relatime 0 0 devpts /dev/pts devpts rw,relatime 0 0 tmpfs /var/run tmpfs rw,nosuid,nodev,noexec 0 0 tmpfs /var/lock tmpfs rw,nosuid,nodev,noexec 0 0 securityfs /sys/kernel/security securityfs rw,relatime 0 0
Does something like this look reasonable? (I can't think of a way to test safely) proc /proc proc defaults 0 0 UUID=c753a899-0637-4963-9f77-a825051bb917 / ext3 defaults,errors=remount-ro 0 1
It looks a bit sparse, to say the least! Should I have something in there for swap and CD (neither of which are in the mount output)?
That looks good for the root filesystem...
Yes, you'll want the swap device too, at least, and you'll want the path for the cdrom drive...
So, something more like:
--- Start fstab ---
proc /proc proc defaults 0 0 UUID=c753a899-0637-4963-9f77-a825051bb917 / ext3 defaults 0 0 /dev/sda2 none swap sw 0 0 /dev/cdrom /media/cdrom0 udf,iso9660 user,noauto 0 0
--- End fstab ---
You can find the name of the swap partition using:
# swapon -s
/dev/cdrom, assuming there's udev, should really point to the first CD drive available (but check in /dev, it maybe that you need to use /dev/cdrom1 or similar)
Cheers,
Brett Parker wrote:
That looks good for the root filesystem...
Yes, you'll want the swap device too, at least, and you'll want the path for the cdrom drive...
So, something more like:
Thanks for that, and for telling me about swapon -s.
The end results, heavily based on the info here, googling, and reasonably clean and similar installs elsewhere, is:
--- Start fstab ---
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 UUID=c753a899-0637-4963-9f77-a825051bb917 / ext3 defaults,errors=remount-ro 0 1 /dev/md0 /storage ext3 defaults 0 1 /dev/sda5 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
--- End fstab ---
I write this as I wait to see if the server comes back up from a reboot....
... which it has. Thanks!
On Mon, 2008-05-12 at 12:27 +0100, Mark Rogers wrote:
In the good old days I understood fstab, but now with UUIDs etc I'm a bit out of date.
You don't *have* to use the UUID's there is still nothing stopping you falling back to the old way with device nodes. Of course that depends on you knowing what partition mounts where but if you only have one partition plus swap it shouldn't be too hard to figure out.
Wayne Stallwood wrote:
You don't *have* to use the UUID's there is still nothing stopping you falling back to the old way with device nodes.
What is the advantage of the UUID method?
(On the rather shaky assumption that all progress is made for good reasons.)
On Mon, 2008-05-12 at 18:08 +0100, Mark Rogers wrote:
What is the advantage of the UUID method?
The advantage is that in some cases the device nodes can end up being pointed to different drives (say for example a laptop that gets plugged and unplugged from a docking station that has it's own drive bay, or somebody messing about with cables/adding drives in a desktop) whereas the UUID route uses the volume id of the partition so in theory you can put that drive on any controller/ any channel and (assuming grub is also configured for UUID and your BIOS will boot from any device) the machine will still work fine.
eons ago I remember I had a Dell laptop with a hotplug cdrom/floppy and I would get different drives on different device nodes depending on whether it was booted with the floppy, cdrom or 2nd battery in it's hotplug bay. UUID would have fixed this.
On a server it can probably be assumed that this isn't going to happen or if it does it will be done by someone expecting to have to deal with it.
However it would also be of particular benefit I suspect in softraid configurations and save the "ooh what order were these in again" panic
(On the rather shaky assumption that all progress is made for good reasons.)
Yeh right :)
If your systems still running you might be able to copy /etc/mtab.
regards,
Keith ____________ The best use of your mind is to distrust it. - François Fénelon
-----Original Message----- From: main-bounces@lists.alug.org.uk [mailto:main-bounces@lists.alug.org.uk] On Behalf Of Mark Rogers Sent: 12 May 2008 10:35
I just carelessly overwrote my /etc/fstab file with the following: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee /etc/fstab .. when I meant: echo /dev/md0 /storage ext3 defaults 0 1 | sudo tee -a /etc/fstab (-a means append)
Any suggestions for recovery?
This is a fresh install of Ubuntu 8.04 Server, so worst case I will have to reinstall the O/S but I'd like to recover if possible, not least so I know how to do it next time I am silly!
[Feeling very foolish right now...]
____________________________________________________________________________________ Kewill Systems Plc Tel: +44 (0) 160 377 9300 Email:keith.watson@kewill.com 26 Hellesdon Park Rd., DDI: +44 (0) 160 377 9324 Web:www.kewill.com Norwich, Norfolk, NR6 5DR Fax: +44 (0) 160 377 9303 ____________________________________________________________________________________ ________________________________
IMPORTANT NOTICE: This e-mail, and each of any attachments transmitted with it, is confidential, is the property of Kewill Systems plc ("Kewill"), and is intended solely for the information of the individual/entity to whom this e-mail is addressed. It may also be privileged or protected by other legal rules. If you have received it by mistake, please notify the author immediately by replying to this e-mail and then destroy/delete this e-mail and all attachments (if any). If you are not the intended recipient you must not use, disclose, distribute, copy, print, or rely on this e-mail. In accordance with Kewill's internal policy e-mails sent and/or received may be monitored. Whilst Kewill takes reasonable precautions (including use of anti-virus software) it accepts no responsibility for any loss or damage should this e-mail contain any virus, or similar destructive or mischievous code. © Kewill Systems plc 2007. Kewill Systems plc (1037515) - registered in England at Bramley House, The Guildway, Old Portsmouth Road, Artington, Guildford, GU3 1LR.
On Mon, 2008-05-12 at 10:34 +0100, Mark Rogers wrote:
This is a fresh install of Ubuntu 8.04 Server, so worst case I will have to reinstall the O/S but I'd like to recover if possible, not least so I know how to do it next time I am silly!
I think if you don't fancy doing what others have suggested and manually rebuilding fstab then the repair option from the installation media will automagically fix this for you. Personally I would try what Brett says first though, if only for the learning experience.