how to mount dvd-rw drive/create mount point
I looked in /dev. A file there was called dvd. I entered ' ls -al /dev/dvd ' and it told me that this was a link to /dev/sr0. I inferred that from this response:
lrwxrwxrwx 1 root root 3 Apr 24 15:56 /dev/dvd -> sr0
The first 'l' means that it is a link, not a real file.
Then, I looked at /. There was a directory there called 'mnt', the usual node for subdirectories of mounted peripheral devices. It was empty.
I made a subdirectory of /mnt using:
sudo mkdir /mnt/cdrom
Then, I mounted sr0 there with:
sudo mount /dev/sr0 /mnt/cdrom
To see, I looked at it:
ls /mnt/cdrom
It came up with a lot of right-looking stuff, so I concluded success.
CD/DVD Drive Rule: Mount Drive Upon Insert to "/media/DVD"
Do this if you want to restore auto-mounting with some control over how it is done.
- Auto-creates mount point upon insertion of medium
- Auto-mounts medium to mount point with specific permissions
- Auto-removes mount point upon removal of medium
Action: CD/DVD Tray has media and is pulled in
You have to tell your system to react this this action. You can have it run a mount script (any custom script). To do this, you need to create a new rule in the lib/udev/rules.d
folder. These commands need to be run as root (use the prefix sudo
for the following commands to run them as root or become the root user with sudo -s
- Make a new file and call it autodvd.rules
touch /lib/udev/rules.d
- Look for info about your CD/DVD drive by running
udevadm info --query=all --attribute-walk --name=/dev/sr0
(root not necessary here, but works both ways) Look for something that uniquely identifies your drive (for better or for worse I pickedATTRS{vendor}=="HL-DT-ST"
, which is my drive (yours will be different unless you happen to own the same drive as me). Copy it down somewhere for later. You can take some time to look over this file and compare it with the rule example below. The SUBSYSTEM and ATTRS can be found in it. - Edit your new rule (you can use whatever editor you choose, I use
vim /lib/udev/rules.d
, butnano /lib/udev/rules.d
works too and is easy. Add these things, editing your ATTRS to match yours (this is the sensitive part, you might have to pick a different attribute if it doesn't work) and correct the YOURUSER and YOURGROUP fields:
KERNEL=="sr[0-9]*", SUBSYSTEM=="block", ATTRS{vendor}=="HL-DT-ST", SYMLINK+="dvdburner", OWNER="YOURUSER", GROUP="YOURGROUP" ACTION=="change",RUN+="/home/YOURUSER/Scripts/Bash/automountdvd.sh"
- The
KERNEL=="sr[0-9]*"
just means it will test allscsi
devices (sr0-sr9) - The
SYMLINK
is just a symbolic link to the drive (like/dev/cdrom
is to the real/dev/sr0
)
You may need to reload all of the udev rules:
udevadm control --reload rules
reload udev
udevadm trigger
Mount Script
Save the following somewhere like: /home/YOURUSER/Scripts/Bash/automountdvd.sh
and correct the YOURUSER and YOURGROUP fields. Oh by the way, it is dangerous to put this script in the user folder, because it will be run by root, which means if somebody hacks your user folder, they can adjust the script to do whatever they want and root will run it (and likely succeed, because the root user has full control over the system) Probably better to hide it in a folder that only root can see. If you are experimenting, it is fine.
#!/bin/bash
{
mountpoint="/media/DVD"
user=YOURUSER
group=YOURGROUP
uid=$(id -u ${user})
gid=$(id -g ${group})
FS_TYPE="`blkid /dev/sr0 | grep -o 'udf'`"
if [ ${FS_TYPE} == 'udf' ]; then
echo "ID_CDROM_MEDIA set to 1, creating ${mountpoint} and attempting to mount DVD."
mkdir -p ${mountpoint} && chown ${user}:${group} ${mountpoint}
mount -t ${FS_TYPE} -o ro,uid=${uid},gid=${gid} /dev/sr0 ${mountpoint}
echo "DVD mounted at ${mountpoint}."
else
echo "Attempting to unmount -l ${mountpoint}."
umount -l ${mountpoint}
rm -rf ${mountpoint}
echo "Unmounting ${mountpoint} and removing folder ${mountpoint}."
fi
} &>> "/var/log/autodvd.log" &
If you want to mount a cd/cdrom/dvd/whatever manually, you should first look in the directory /dev, for example with ls /dev
. It is probably called dvd1. Then mount it with sudo mkdir /mnt/dvd1 && sudo mount /dev/dvd1 /mnt/dvd1
.