[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#611569: apt-cdrom doesn't work on GNU/kFreeBSD



I wrote:
> Looking at the syslog, apt says it's going to use /media/cdrom as
> the moint point but then mount seems to be run with /cdrom.
> Screenshot of this weirdness attached.

That was a red herring, apt was not using /cdrom. (d-i does)
Forgotten screenshot attached anyway.

> I see that the generated fstab on kFreeBSD contains:
> 
> /dev/cd0	/media/cdrom0	cd9660	ro,auto		0	0
> 
> Why is the mount point different? I don't know yet. If I correct this
> to use "/media/cdrom0", then apt-cdrom add works in d-i with no further
          /media/cdrom <-- correction: removing the "0" works..
> changes.

/media/cdrom is a symlink to /media/cdrom0. Seems that that
configuring apt to use the /media/cdrom symlink, while the fstab has
/media/cdrom0 works on Linux, but somehow not on kFreeBSD.

Aha! On Linux, "mount /media/cdrom" will follow the symlink and mount
/media/cdrom0 as configured in fstab. On kfreeBSD, mount does not have
those smarts, it seems.

The underlying problem on kFreeBSD is that "mount /media/cdrom" fails.
If mount on kFreeBSD cannot handle a symlinked mount point, then d-i
should not configure the mount points like that. (It also sets up /media/usb
as a symlink to /media/usb0.) That will fix apt-cdrom as well as allowing
users to hand-mount removable media as they probably expect to be able to.

I propose the attached patch to partman-target. I have tested it,
and it works.

-- 
see shy jo

Attachment: cdrom.png
Description: PNG image

commit a7d3da962eae2d8d950984c780fa8d6d911acb48
Author: Joey Hess <joey@kitenet.net>
Date:   Tue Feb 1 13:58:50 2011 -0400

    Fix cdrom mountpoint setup on kFreeBSD
    
    On kFreeBSD, mount does not follow symlinks in the mountpoint, so the way
    mount points were set up for removable media caused problems. So on that OS
    only, rather than making /media/cdrom -> /media/cdrom0, and putting
    /media/cdrom0 in /etc/fstab, instead make /media/cdrom a directory, and put
    /media/cdrom in /etc/fstab. This way¸  "mount /media/cdrom", "mount
    /media/usb" etc all work, and so does apt-setup add.  Closes: #611569
    
    (Note that additional CD devices will be set up as /media/cdrom1, etc, same
    as before. This leads to the minor inconsistency on kFreeBSD that "mount
    /media/cdrom1" is needed for the second CD, while "mount /media/cdrom0"
    won't work for the first, but I don't see a way to avoid that.)

diff --git a/debian/changelog b/debian/changelog
index 1a71ffa..666c8bf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,24 @@
 partman-target (72) UNRELEASED; urgency=low
 
+  [ Christian Perrier ]
   * Point users to blkid instead of non-existing vol_id (on the
     installed system) in /etc/fstab file header
     Closes: #608996
 
+  [ Joey Hess ]
+  * On kFreeBSD, mount does not follow symlinks in the mountpoint, so
+    the way mount points were set up for removable media caused problems.
+    So on that OS only, rather than making /media/cdrom -> /media/cdrom0,
+    and putting /media/cdrom0 in /etc/fstab, instead make /media/cdrom
+    a directory, and put /media/cdrom in /etc/fstab. This way¸ 
+    "mount /media/cdrom", "mount /media/usb" etc all work, and so does
+    apt-setup add.  Closes: #611569
+    (Note that additional CD devices will be set up as /media/cdrom1, etc,
+    same as before. This leads to the minor inconsistency on kFreeBSD that
+    "mount /media/cdrom1" is needed for the second CD, while
+    "mount /media/cdrom0" won't work for the first, but I don't
+    see a way to avoid that.)
+
  -- Christian Perrier <bubulle@debian.org>  Wed, 05 Jan 2011 19:28:49 +0100
 
 partman-target (71) unstable; urgency=low
diff --git a/finish.d/fstab_removable_media_entries b/finish.d/fstab_removable_media_entries
index 41f36dd..d0dd60f 100755
--- a/finish.d/fstab_removable_media_entries
+++ b/finish.d/fstab_removable_media_entries
@@ -33,13 +33,20 @@ populate_media () {
 	options=$3
 	shift; shift; shift
 	mkdir -p /target$MEDIA
-	if [ "$1" ]; then
+	symlink_to_0=1
+	if [ "`udpkg --print-os`" = kfreebsd ]; then
+		symlink_to_0=""
+	fi
+	if [ "$1" ] && [ "$symlink_to_0" ] ; then
 		rm_dir_or_link /target$MEDIA/$category
 		ln -s ${category}0 /target$MEDIA/$category
 	fi
 	number=0
 	while [ "$1" ]; do
 		mount_point="$MEDIA/$category$number"
+		if [ ! "$symlink_to_0" ] && [ "$number" = 0 ]; then
+			mount_point="$MEDIA/$category"
+		fi
 		addfstab "$1" "$mount_point" "$fs" "$options" 0 0
 		rm_dir_or_link /target$mount_point
 		mkdir -p /target$mount_point

Attachment: signature.asc
Description: Digital signature


Reply to: