Posts Tagged ‘mount’

And now I know…

Sunday, August 15th, 2010

… why it is a good idea, nay a must, to keep a live cd around.

After a system upgrade earlier tonight I got a message about an new sudoers file (placed in /etc/sudoers.pacnew) that had been downloaded and wanted me to take a look at it.

So I made a couple of mistakes here:

  1. I didn’t stop to think it through enough, which lead to…
  2. I didn’t edit the new sudoers file first before moving it in place, but also…
  3. I MOVED the original file to a backup spot, instead of COPYING it
  4. Of course, none of this would have mattered, had I logged into the root account before doing stuff, instead of relying on sudo… for tampering with sudoers… I’m so smart! S-M-R-T.

So, instead of doing things the right way, i.e.:

$ sudo su
# cp /etc/sudoers /etc/sudoers.bak
# vim -p /etc/sudoers.pacnew /etc/sudoers.bak
# mv /etc/sudoers.pacnew /etc/sudoers

what I did was (NEVER EVER DO THIS!):

$ sudo mv /etc/sudoers /etc/sudoers.bak

The instant I hit enter, I got a sinking feeling, knowing I’d frakked up. Attempting to undo the damage

$ sudo mv /etc/sudoers.bak /etc/sudoers

only resulted in an error message:

sudo: can’t stat /etc/sudoers: No such file or directory
sudo: no valid sudoers sources found, quitting

There might have been a root password set, but if so I couldn’t for the life of me remember it. Great! What now?

I knew of course I could access the filesystem from a live-cd but I hadn’t actually needed to do this before, so I was unsure about how to proceed once in the live-session (I had a vague notion about having to fiddle with chroot, something I have not done much of) but as luck would have it, hesa was online and helped me out (no need for chroot, just mount the partition, move some files, unmount, restart.)

Upon booting into Knoppix it was a small matter of

  1. remembering which of the disk, and partitions which housed the root-partition, and
  2. mounting it:

$ sudo mount /dev/sdb3 /media/sdb3
$ cd /media/sdb3/etc/
$ sudo mv sudoers.bak sudoers
$ cd /
$ sudo umount /media/sdb3
$ sudo reboot

Now, this would have been the sane thing to do, and start over from inside Arch… but instead I moved sudoers.pacnew into sudoers, forgot to edit it, rebooted, realized my new mistake, rebooted again (a hassle, since sudo reboot wasn’t available), remounted sdb3, edited sudoers adding myself again, and finally rebooted. And all was well.

So now I know, first hand… Live-CDs FTW!

:wq

Easy identification of USB storage disks

Sunday, March 1st, 2009

I have during the last couple of weeks begun the ponder about the hard drives in my computers. Specifically how much longer they are going to live. Today I rectified the problem by purchasing a 500Gb USB disk, formatted it to ext3 and began the process of backing up all the stuff I wanted to survive in the event of a hard drive failure. I figured the fastest way to get the data onto the disk, was to mount it in each separate system (since the computers are located in direct vicinity of each other.

One of them runs as a server, no X, no desktop environment, no automounting. Automounting is a nice feature and having grown accustomed to having it around, I had to look up how to identify the disk in /dev/.

Enter this post, which neatly solved my problem. I modified it a bit however, issuing:

sudo tail -f /var/log/messages

before I plugged in/powered up the disk. From there on I could easily identify the disk as /dev/sdb and I proceeded to mount /dev/sdb1 to a mount point (/media/disk)

sudo mount /dev/sdb1 /media/disk

Piece of cake, when you know what to mount ;D

How to give an ftp-user access outside the home directory

Sunday, September 7th, 2008

Today I found myself needing to share a directory inside my home directory, with the default ftp user on my system. The reason for someone wanting to break out of a ftp servers chroot jail may be several, in my case it was lack of space on my hard drive. Normally, if I have something I need to share over the network, I’ll just copy it into the home of the ftp user, and then let whoever connect through that user, but today it was a couple of fairly large files, so copying wasn’t an option.

I tried the naive approach first, a symbolic link from the ftp directory to my directory holding the files. This didn’t work. So I hit Google, and came up with this:

http://www.ducea.com/2006/07/27/allowing-ftp-access-to-files-outside-the-home-directory-chroot/

It basically boils down to this:

$ mount --bind /directory/to/share/ /home/ftp_user/share

This mounts the /directory/to/share/ inside /home/ftp_user/share. Nifty!
If there is a need to create this link permanently, you’ll want to check out Marius post as it explains how to do this as well.