View previous topic :: View next topic |
Author |
Message |
v1pEr n00b
Joined: 20 Apr 2009 Posts: 63
|
Posted: Tue Nov 17, 2009 6:37 am Post subject: [SOLVED] Gentoo install + encryption + raid != monitor disk? |
|
|
So when I did my gentoo install some time ago (about a year already I think) I decided to go for encryption and raid 1 for my OS disks. Lucky for me I found this guide on the wiki how to do encryption, and I got another one about how to do raid (which was easier than the encryption )
Six months later I encountered an issue which I blamed on my bad implementation of the above guide: I can't monitor the diskspace of my OS disks. Let's just say I'm a monitoring and statistics guy and I was annoyed by it, but I monitor my 2 other data raids so I kinda shushed myself back to happiness.
Until yesterday I had some samba problems and had to read that my OS disk was full! I've had some nasty issues with a full OS disk in the past and decided to clean up a bit, but I'm on a time bomb here so I need some help.
What can I do to fix it so I can monitor my diskspace again?
I use below initramfs script to decrypt my OS disk, assemble the raid and start booting from it:
Code: |
#!/bin/ash
#
# Executables
#
MOUNT="/bin/mount"
SWITCH_ROOT="/sbin/switch_root"
LOADKMAP="/sbin/loadkmap"
CRYPTSETUP="/sbin/cryptsetup"
ASH="/bin/ash"
MDADM="/sbin/mdadm"
#
# Needed functions
#
msg() {
if [ "${DEBUG}" == "true" ]; then
echo $1
fi
}
processOptions() {
# First we set some of the options to their default state
DEBUG="false"
rootdev=
# Parse the kernel parameters line and set the needed options accordingl y
for i in `cat /proc/cmdline`; do
case $i in
cryptdebug)
DEBUG="true"
;;
root=*)
rootdev=`echo $i|cut -d"=" -f2`
;;
esac
done
}
initScreen() {
# Clear the screen
clear
# Display messagefile if it does exist
if [ -f "/etc/msg" ]; then
cat /etc/msg
fi
}
enableProcfs() {
# Mount the procfs
# Needed by cryptsetup
msg "Mounting procfs"
${MOUNT} -t proc none /proc
}
switchToNewRootfs() {
newRoot=$1
# Create /dev/console in new rootfs if it does not exist
msg "Creating /dev/console in mounted rootfs"
mknod "$1/dev/console" c 5 1 2>&1 >/dev/null
msg "Switching to new rootfs"
cd "${newRoot}"
exec ${SWITCH_ROOT} -c /dev/console . /sbin/init
}
setKeymapping() {
keymap=$1
msg "Loading german keymap '${keymap}'"
${LOADKMAP} < "/etc/keymaps/${keymap}"
}
loadRaid() {
# /dev/md1 = /dev/sda1 + /dev/sdb1
${MDADM} --assemble /dev/md1 /dev/sda1 /dev/sdb1 --run
# /dev/md3 = /dev/sda3 + /dev/sdb3
${MDADM} --assemble /dev/md3 /dev/sda3 /dev/sdb3 --run
}
luksOpen() {
if [ "${rootdev}" == "" ]; then
echo "No root device was specified."
echo "Append root=<device> to your kernel command line"
echo "Dropping you to a minimal shell for recovery"
echo
${ASH}
fi
retval=1
#while [ $retval -ne 0 ]; do
msg "Opening cryptoluks device"
${CRYPTSETUP} luksOpen ${rootdev} root
retval=$?
#done
msg "Mounting newroot"
${MOUNT} /dev/mapper/root /mnt/root
}
#
# Main function
#
main() {
# Some hardware needs time to settle before we can use it
sleep 10
initScreen
enableProcfs
processOptions
setKeymapping "defkeymap_V1.0.map.gz"
loadRaid
luksOpen
switchToNewRootfs "/mnt/root"
}
# Run the main function
main
|
my fstab looks like this:
Code: | /dev/md1 /boot ext2 noauto,noatime 1 2
/dev/sda2 none swap sw 0 0
/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0 |
As you see there is no line for / in my fstab, I had to delete it because otherwise the system didn't want to boot (got a message saying already mounted or something, it's been a while since the original install)
Can anybody help me here? I'm kind of anxious now to change much about the init script because, how simple it is, it took quite some time for me to get this far. But I really need to monitor diskspace now, so what is the best way to do it?
Oh yes, also df also shows nothing:
Code: | Filesystem Size Used Avail Use% Mounted on
udev 11M 369k 11M 4% /dev
shm 1.1G 0 1.1G 0% /dev/shm
/dev/mapper/data1 2.6T 2.4T 174G 94% /mnt/data1
/dev/mapper/data2 1.1T 868G 133G 87% /mnt/data2
/dev/md1 40M 27M 12M 70% /boot |
I would need a line for /dev/mapper/root there
Output of mount:
Code: | none on /proc type proc (rw)
proc on /proc type proc (rw,nosuid,nodev,noexec)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
/dev/mapper/data1 on /mnt/data1 type xfs (rw)
/dev/mapper/data2 on /mnt/data2 type xfs (rw)
/dev/md1 on /boot type ext2 (rw,noatime)
|
ANY help will be greatly appreciated!
Last edited by v1pEr on Wed Nov 18, 2009 6:13 am; edited 1 time in total |
|
Back to top |
|
|
frostschutz Advocate
Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Tue Nov 17, 2009 7:02 am Post subject: |
|
|
The initramfs should mount the root partition as read only, so once it hands off booting to the init script, init can take care of fsck the root partition when necessary (it has to have an entry in fstab for that). if you mount it read write you will get errors. it should also unmount any stuff it mounted besides the root partition (i.e. proc and sys), since that will be mounted again on the root partition by the root init.
Free disk space is a filesystem thing. It does not matter at all how that filesystem is stored (normal, raid, encrypted, network, magic...). If free space in a filesystem is not displayed properly by df, it's most likely corrupt somehow.
fix your fstab and initramfs (either by genkernel or using the Initramfs page in the Gentoo wiki), fsck your filesystems. |
|
Back to top |
|
|
v1pEr n00b
Joined: 20 Apr 2009 Posts: 63
|
Posted: Tue Nov 17, 2009 9:10 pm Post subject: |
|
|
Wow that was
1) quick
2) correct
3) to the point
Perfect, I did as you suggested (add / to fstab and mount / read-only in the init script) and now I can see free disk space with df again. Thanks a lot! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|