#594052 debootstrap: create example /etc/hosts and /etc/fstab?

Package:
debootstrap
Source:
debootstrap
Submitter:
Colin Watson
Date:
2024-01-30 12:15:04 UTC
Severity:
wishlist
Tags:
#594052#5
Date:
2010-08-23 11:45:12 UTC
From:
To:
In https://bugs.launchpad.net/ubuntu/+source/debootstrap/+bug/110144,
Evan Klitzke (CCed) suggested that debootstrap could be improved to
create a few more skeleton system configuration files by default.  I
didn't agree with all his points (see the Ubuntu bug for details), but
it does seem that creating skeleton /etc/hosts and /etc/fstab would be
beneficial - I've verified that this won't break netcfg or
partman-target respectively.

The essence of Evan's patch was (I've removed a bit about
/etc/network/interfaces since I feel that's better handled elsewhere,
and apologies that this is actually against the current Ubuntu script
but I'm sure the intent will be clear):

Index: scripts/gutsy
===================================================================
--- scripts/gutsy	(revision 64498)
+++ scripts/gutsy	(working copy)
@@ -53,10 +53,45 @@

     setup_etc
     if [ ! -e "$TARGET/etc/fstab" ]; then
-        echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
+        echo '# /etc/fstab: static file system information.' > $TARGET/etc/fstab
+        echo '#' >> $TARGET/etc/fstab
+        echo '# file system    mount point   type    options                  dump pass' >> $TARGET/etc/fstab
+        echo 'proc             /proc         proc    defaults                 0    0' >> $TARGET/etc/fstab
+        echo 'sys              /sys          sysfs   defaults                 0    0' >> $TARGET/etc/fstab
+        echo '' >> $TARGET/etc/fstab
+        echo '# Here are some example entries; uncomment these lines and add the correct' >> $TARGET/etc/fstab
+        echo '# device name. Note that the recommended way to mount partitions is now by UUID' >> $TARGET/etc/fstab
+        echo '# rather than device name; see https://wiki.ubuntu.com/LibAtaForAtaDisks for' >> $TARGET/etc/fstab
+        echo '# details. You can find out the UUIDs of your partitions by running blkid.' >> $TARGET/etc/fstab
+        echo '' >> $TARGET/etc/fstab
+        echo '#/dev/fd0         /mnt/floppy   auto    noauto,rw,sync,user,exec 0    0' >> $TARGET/etc/fstab
+        echo '#/dev/cdrom       /mnt/cdrom    iso9660 noauto,ro,user,exec      0    0' >> $TARGET/etc/fstab
+        echo '#' >> $TARGET/etc/fstab
+        echo '#/dev/XXX         none          swap    sw                       0    0' >> $TARGET/etc/fstab
+        echo '#' >> $TARGET/etc/fstab
+        echo '#/dev/XXX         /             ext3    defaults                 0    1' >> $TARGET/etc/fstab
+        echo '#/dev/XXX         /boot         ext3    ro,nosuid,nodev          0    2' >> $TARGET/etc/fstab
+        echo '#UUID=XXX         /home         ext3    rw,nosuid,nodev          0    2' >> $TARGET/etc/fstab
+        echo '#UUID=XXX         /tmp          ext3    rw,nosuid,nodev          0    2' >> $TARGET/etc/fstab
+        echo '#UUID=XXX         /var          ext3    rw,nosuid,nodev          0    2' >> $TARGET/etc/fstab
+        echo '#UUID=XXX         /usr          ext3    rw,nodev                 0    2' >> $TARGET/etc/fstab
+        echo '#UUID=XXX         /home         ext3    rw,nosuid,nodev          0    2' >> $TARGET/etc/fstab
         chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
     fi

+    if [ ! -e "$TARGET/etc/hosts" ]; then
+        echo '127.0.0.1       localhost' > "$TARGET/etc/hosts"
+        echo '' >> "$TARGET/etc/hosts"
+        echo '# The following lines are desirable for IPv6 capable hosts' >> "$TARGET/etc/hosts"
+        echo '::1     ip6-localhost ip6-loopback' >> "$TARGET/etc/hosts"
+        echo 'fe00::0 ip6-localnet' >> "$TARGET/etc/hosts"
+        echo 'ff00::0 ip6-mcastprefix' >> "$TARGET/etc/hosts"
+        echo 'ff02::1 ip6-allnodes' >> "$TARGET/etc/hosts"
+        echo 'ff02::2 ip6-allrouters' >> "$TARGET/etc/hosts"
+        echo 'ff02::3 ip6-allhosts' >> "$TARGET/etc/hosts"
+        chown 0:0 "$TARGET/etc/hosts"; chmod 644 "$TARGET/etc/hosts"
+    fi
+
     if doing_variant fakechroot; then
         setup_devices_fakechroot
     else

I think the proposed /etc/hosts is probably fine, modulo verification
that it's bitwise-identical with netcfg's default.  Regarding
/etc/fstab, I think we should be a bit less verbose than that and more
generic rather than referring to the Ubuntu wiki, and we should make
sure everything is synced up with partman-target.  I'm also not sure
about removing "UNCONFIGURED FSTAB FOR BASE SYSTEM" - I remember that
that used to be a token that some software checked for, and, while that
doesn't seem to be the case in d-i any more, I'd be cautious about
removing it all the same.

Does anyone have any thoughts on this?

Thanks,

#594052#8
Date:
2010-08-23 13:18:45 UTC
From:
To:
Colin Watson, le Mon 23 Aug 2010 12:45:12 +0100, a écrit :

Mmm, aren't you actually looking for crosshurd? (which should really be
called crossdebian nowadays). AIUI, using debootstrap is just meant for
chroots & such.

Samuel

#594052#13
Date:
2017-01-23 22:00:55 UTC
From:
To:
Dear Customer,

Your parcel was successfully delivered January 23 to USPS Station, but our courier cound not contact you.

Review the document that is attached to this e-mail!

Warm regards,
Claude Russo,
USPS Senior Delivery Manager.

#594052#18
Date:
2017-01-25 15:40:38 UTC
From:
To:
Dear Customer,

Your item has arrived at January 22, but our courier was not able to deliver the parcel.

Please review delivery label in attachment!

Yours respectfully,
Ricky Madden,
USPS Support Agent.

#594052#23
Date:
2017-02-23 16:36:50 UTC
From:
To:
Dear Customer,

This is to confirm that your item has been shipped at February 19.

Please check the attachment for complete details!

Sincerely yours,
Ralph Tuttle,
UPS Mail Delivery Manager.

#594052#28
Date:
2017-03-31 16:30:49 UTC
From:
To:
Dear Customer,

This is to confirm that your item has been shipped at March 27.

Postal label is enclosed to this e-mail. Please check the attachment!

Thank you for your assistance in this matter,
Martin Crane,
UPS Station Manager.

#594052#33
Date:
2018-06-05 02:42:30 UTC
From:
To:
Hi,

 You mean, adding /etc/fstab sample is harm for hurd (or kfreebsd)?
 If so, how about if we can apply it for only linux?

#594052#38
Date:
2018-06-05 06:58:21 UTC
From:
To:
Hideki Yamane, le mar. 05 juin 2018 11:42:30 +0900, a ecrit:
chroots etc. where e.g. fstab doesn't even make sense.  The debian
installer then for instance has scripts to populate fstab & hosts
according to what it knows about the content that should be put.

Crosshurd (again, should be called crossdebian, it's not hurd-specific
at all), however, does know how to populate fstab & hosts with sample
files according to the system, and thus I think it answers the need
expressed here.

We could also see at merging deboostrap and crosshurd, since they
are two tools which do almost the same thing, and see crosshurd's
README.Debian suggesting so.

There is no reason to do it only for Linux.

Samuel

#594052#43
Date:
2018-06-05 07:29:26 UTC
From:
To:
Hi,

 Thank you for your explanation.

 debootstrap is used to create just not simple chroot but for containers,
 like lxc, systemd-nspawn, etc., so adding sample /etc/fstab and hosts is
 better for them, IMO.

 Okay, I'll check it.
 BTW, is there any known blocker to merge them?

#594052#48
Date:
2018-06-05 07:34:27 UTC
From:
To:
Hideki Yamane, le mar. 05 juin 2018 16:29:26 +0900, a ecrit:

Ok, then it'd be good to pick up what is already in crosshurd into
debootstrap.

Samuel

#594052#53
Date:
2018-06-05 16:58:16 UTC
From:
To:
Hi,

Hideki Yamane <henrich@iijmio-mail.jp> (2018-06-05):

There are many things one might want to put inside a /etc/fstab
depending on the system being set up, and the current behaviour (not
listing anything) looks sane enough to me; systemd does the job mounting
many filesystems nowadays, so I'm not sure we need to add anything there.

/etc/hosts already gets contents through netbase's postinst, but only if
it's not present already. Let's not duplicate its postinst?


Cheers,

#594052#58
Date:
2024-01-30 12:14:27 UTC
From:
To:
This seems unnecessary for debootstrap. Can this be closed?