specifying mount options for partition [SOLVED]

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
deniros
Posts: 50
Joined: Tue 20 Jun 2006, 22:46
Location: Belgium
Contact:

specifying mount options for partition [SOLVED]

#1 Post by deniros »

I have a frugal installation of fatdog64 on my SSD. I have 2 partitions on this harddrive.

sda1 and sda2.

I have formatted sda2 with ext4, and used the /etc/fstab to specify the mount options. ( to add the discard parameter)
Now this works. i have tested this.

Now, I have installed puppy on sda1, and my storage file is also on that disk. I was wondering if I could format that drive to ext4 and specify the discard function. I saw something in /etc/mtab, but i cannot change that file.

Does anyone know where i can set this parameter for the disk that is mounted because my installation and storage file is on that disk?
Last edited by deniros on Fri 09 Dec 2011, 23:46, edited 1 time in total.

tytower

#2 Post by tytower »

never heard of discard before but to assist any others reading this it is in the "mount" command
Mount options for ext4
discard/nodiscard
Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done.

I had to do a google for SSD too though I had a fair idea what was meant if you can stand the broken english
http://forums.techarena.in/guides-tutorials/1131289.htm

When you use Capitals putting the expanded name in brackets after the first use helps -SSD (Solid State Drive)

User avatar
deniros
Posts: 50
Joined: Tue 20 Jun 2006, 22:46
Location: Belgium
Contact:

#3 Post by deniros »

Thanks for your answer, but that was not what i meant. I know how discard works, and how to enable it using /etc/fstab. And it works for a manually mounted sda2 partition. I've tested it with hdparm.

The situation is like this:

I have 1 SSD with 2 partitions. I have fatdog64 (frugal) installed on SDA1 (which ofcourse also contains the sfs and personal storage file).

I also have SDA2 mounted with the parameter "discard". And trim works on this partition.

My question is: in /etc/mtab you see all mounted devices. I don't know how to add the parameter "discard" for sda1, where puppy is installed (frugal). I have searched through many config files, and I don't know where this is specified. adding sda1 to fstab with the discard option doesn't work.

So it would be great if anyone has the knowledge where i can modify this and would share it

currently, according to /etc/mtab, the mounting options for sda1 are

/dev/sda1 /initrd/mnt/dev_save ext4 rw,noatime,user_xattr,acl,barrier=1,data=ordered 0 0

tytower wrote:never heard of discard before but to assist any others reading this it is in the "mount" command
Mount options for ext4
discard/nodiscard
Controls whether ext4 should issue discard/TRIM commands to the underlying block device when blocks are freed. This is useful for SSD devices and sparse/thinly-provisioned LUNs, but it is off by default until sufficient testing has been done.

I had to do a google for SSD too though I had a fair idea what was meant if you can stand the broken english
http://forums.techarena.in/guides-tutorials/1131289.htm

When you use Capitals putting the expanded name in brackets after the first use helps -SSD (Solid State Drive)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

It seems that you want the sda1 being passed the discard parameter at boottime ?

If so , you would probably need to edit the init script in the initrd.gz .
OR
I think it should be possible to add something to

Code: Select all

kernel /[puppydir]boot/vmlinuz root=/dev/sda1 ro vga=normal rootfstype=ext4 rootflags=discard[,otheroption1,...]
google for kernel-parameters.txt for more details .

Will probably test them , too ... ;)
This also is from kernel source of 2.6.37 and i don't actually know since which kernel version these two root parameters are supported

User avatar
deniros
Posts: 50
Joined: Tue 20 Jun 2006, 22:46
Location: Belgium
Contact:

#5 Post by deniros »

Hi Karl,

That option with adding that stuff into grub isn't working. it loads, but with the same default mount options.

I haven't tried to edit the init script in init.gz. i don't even know how to do that, and it seems like a painfull solution for a simple parameter. But thanks anyway for your reply.

My safe file is 512 mb, so it probably takes 200 saves before the SSD "thinks" it's full, and then it will get performance on the par with a regular harddrive ;)

Barry probably knows how to do it, but i don't want to bother him with this problem.

Karl Godt wrote:It seems that you want the sda1 being passed the discard parameter at boottime ?

If so , you would probably need to edit the init script in the initrd.gz .
OR
I think it should be possible to add something to

Code: Select all

kernel /[puppydir]boot/vmlinuz root=/dev/sda1 ro vga=normal rootfstype=ext4 rootflags=discard[,otheroption1,...]
google for kernel-parameters.txt for more details .

Will probably test them , too ... ;)
This also is from kernel source of 2.6.37 and i don't actually know since which kernel version these two root parameters are supported

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#6 Post by Karl Godt »

There are some howtos in the how to section about opening the initrd.gz

it is somewhat

Code: Select all

gunzip initrd.gz
mkdir modify.d
cd ./modify.d
cat ../initrd |cpio -i -d
The code for mounting of init looks like this :

Code: Select all

mntfunc() {
 MNT_T="$1"    #ex: vfat
 MNT_DEV="$2"  #ex: /dev/sda1
 MNT_DIR="$3"  #ex: /mnt/sda1
 MNT_O=""
 [ $4 ] && MNT_O="${4}" #ex: noatime
 case $MNT_T in
  ntfs)
   ntfs-3g $MNT_DEV $MNT_DIR -o umask=0,no_def_opts,noatime,rw 2>/dev/null #default is rw
   ntfsRETVAL=$?
   [ $ntfsRETVAL -eq 0 ] && return 0
   if [ $ntfsRETVAL -eq 14 ];then
    #ntfs-3g $MNTPRMS -o umask=0,no_def_opts,noatime,rw,remove_hiberfile 2>/dev/null
    echo -e "\\033[1;31m" >/dev/console #31=red
    echo -n "ERROR: Windows NTFS hibernated partition, cannot mount" > /dev/console
    echo -e "\\033[0;39m" >/dev/console
    return 14
   else
    ntfs-3g $MNT_DEV $MNT_DIR -o umask=0,no_def_opts,noatime,rw,force 2>/dev/null
   fi
  ;;
  vfat)
   mount -t $MNT_T -o $VFAT_OUT_PARAM $MNT_DEV $MNT_DIR
  ;;
  *)
   if [ "$MNT_O" = "" ];then
    mount -t $MNT_T $MNT_DEV $MNT_DIR
   else
    mount -t $MNT_T -o $MNT_O $MNT_DEV $MNT_DIR
   fi
  ;;
 esac
 return $?
}
would probably need

Code: Select all

ext4)
 if [ "$MNT_O" = "" ];then
mount -t $MNT_T -o discard $MNT_DEV $MNT_DIR
else
mount -t $MNT_T -o ${MNT_O},discard $MNT_DEV $MNT_DIR
fi
;;
above
*)

BOTH init AND /etc/rc.d/rc.sysinit don't parse the /proc/cmdline by default , unless someone does it himself .
I did it for rc.sysinit to check for the nox parameter to boot to cl in full installations .
Like
if [ "`cat /proc/cmdline | grep -i 'nox'`" ]; then touch /tmp/bootcnt.txt;fi
i could think of it for init , too .
There are actually hundreds of kernel parameters to check for to delay boot ;)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#7 Post by Karl Godt »

After reading some pages on the net :
In the 2.6.36 kernel an option controlled by userspace was introduced. For 11.4 userspace control support defaults to disabled. util-linux-ng version greater then v2.18 is required to enable the discard capability. (Note that util-linux-ng was renamed to util-linux in early 2011.)
http://en.opensuse.org/SDB:SSD_discard_ ... 29_support

Puppy-43 -511 have got
# mount-FULL -V
mount (util-linux 2.13-pre7)
BUT RACY
mount from util-linux-ng 2.18 (with libblkid support)

The mount command in the intird traditionally is a symlink to busybox and the busybox traditionally is version-1.4 ! NOT 1.14 .. pretty old .

I am mostly fond of busybox utils but newer ones . Compiling busybox statically may be needed, to OR mount-2.19 statically for the initrd.gz to get this discard parameter to work .

I am on Puppy-43 atm and
mount-FULL -o discard an ext4 partition on usb-flash or normal hard-drive does not work
with 2.6.30.5 kernel and/or mount-FULL-2.13 :
[29893.520841] EXT4-fs: Unrecognized mount option "discard" or missing value

In the initrd i would get a kernel panic i guess .

Another good read is :
http://forums.gentoo.org/viewtopic-t-812509.html

FWIW: I would try racy for this discard SSD purpose .

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#8 Post by amigo »

Mount options for partitions which are automatically mounted during system init should be placed in /etc/fstab.
/etc/mtab is a dynamically-created file which is maintained by 'mount' to show what is currently mounted -or it is a link to /proc/partitions which is automatically created and maintained by the kernel to show currently-*available* partitions -mounted or not.

ICPUG
Posts: 1308
Joined: Mon 25 Jul 2005, 00:09
Location: UK

#9 Post by ICPUG »

I don't know anything about discard or these other suggestions but if the storage file is on sda1 surely it has to be mounted to enable writing to the file.

I know this is true on a standard hard drive. The partition with the save file is always mounted and you cannot unmount it.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#10 Post by Karl Godt »

amigo wrote:Mount options for partitions which are automatically mounted during system init should be placed in /etc/fstab.
/etc/mtab is a dynamically-created file which is maintained by 'mount' to show what is currently mounted -or it is a link to /proc/partitions which is automatically created and maintained by the kernel to show currently-*available* partitions -mounted or not.
This applies for the mount-FULL -a option OR if you are lazy and just want to type mount-FULL /dev/sda1 INSTEAD OF mount-FULL -t $FSTYPE /dev/sda1 /mnt/sda1.

Puppy init appends to an /etc/fstab file for the save-file AND/OR
in case of PUPMODE=3,6,7

Code: Select all

#decide the mount-points...
#unionfs layers:                  RW (top)      RO1               RO2              PUPMODE
#full install, flash drive:      tmpfs          PDEV1                                       3
#First boot (or pfix=ram):  tmpfs                                   pup_xxx.sfs      5
#pup_save is a partition:    PDEV1                                  pup_xxx.sfs      6
#ditto, but flash drive:       tmpfs         PDEV1                pup_xxx.sfs      7
#Normal running puppy:    pup_save.3fs                        pup_xxx.sfs      12
#ditto, but flash drive:       tmpfs         pup_save.3fs      pup_xxx.sfs      13
#Multisession cd/dvd:         tmpfs         folders(tmpfs2) pup_xxx.sfs       77

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#11 Post by Karl Godt »

To mount -o discard apparently is only a kernel version OR configure issue :

# mkdir /mnt/sdb2
# mount-FULL -t ext4 -o discard /dev/sdb2 /mnt/sdb2

# mount
/dev/sdb2 on /mnt/sdb2 type ext4 (rw,relatime,barrier=1,data=ordered,discard)

# uname -r
2.6.37.4-KRG-i586TSC-64GB-1
# mount-FULL -V
mount (util-linux 2.13-pre7)

User avatar
deniros
Posts: 50
Joined: Tue 20 Jun 2006, 22:46
Location: Belgium
Contact:

#12 Post by deniros »

It is definitely a configure issue in my case.

Since, the discard option works on the second partition, sda2, on that same drive. I've put an entry for that in /etc/fstab. And i tested it.

sda1 is automatically mounted, not using /etc/fstab, since puppy is installed on it (frugal) and the save file is there as well. I just don't know where i can modify the mount options of this automatically mounted partition.
Karl Godt wrote:To mount -o discard apparently is only a kernel version OR configure issue :

# mkdir /mnt/sdb2
# mount-FULL -t ext4 -o discard /dev/sdb2 /mnt/sdb2

# mount
/dev/sdb2 on /mnt/sdb2 type ext4 (rw,relatime,barrier=1,data=ordered,discard)

# uname -r
2.6.37.4-KRG-i586TSC-64GB-1
# mount-FULL -V
mount (util-linux 2.13-pre7)

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#13 Post by Karl Godt »

deniros wrote:It is definitely a configure issue in my case.
Since, the discard option works on the second partition, sda2, on that same drive. I've put an entry for that in /etc/fstab. And i tested it.
sda1 is automatically mounted, not using /etc/fstab, since puppy is installed on it (frugal) and the save file is there as well. I just don't know where i can modify the mount options of this automatically mounted partition.
Karl Godt wrote:To mount -o discard apparently is only a kernel version OR configure issue :
# mkdir /mnt/sdb2
# mount-FULL -t ext4 -o discard /dev/sdb2 /mnt/sdb2
# mount
/dev/sdb2 on /mnt/sdb2 type ext4 (rw,relatime,barrier=1,data=ordered,discard)
# uname -r
2.6.37.4-KRG-i586TSC-64GB-1
# mount-FULL -V
mount (util-linux 2.13-pre7)
I meant kernel compile configuration (.config) , not Puppy specific OS configuration .

Nevertheless , /etc/fstab exists in the initrd.gz too and will be used at boot first and after init has switched to the top of the layered filesystems the normal /etc/fstab file may be used by /etc/rc.d/rc.sysinit .

Puppy uses /etc/fstab mainly for /proc and /sys .

mount -a does not get used by Puppy by default .

You would need to adjust initrd.gz as i had shown 6 or 7 posts above .
Navigate to the how to section here , editing initrd also gets discussed there :
GUI to edit initrd.gz

User avatar
deniros
Posts: 50
Joined: Tue 20 Jun 2006, 22:46
Location: Belgium
Contact:

#14 Post by deniros »

Thanks, i should have listened to you the first time. Sorry about that.

editing the initrd.gz according to your info worked. Thanks a lot Karl! oder danke sehr ;) And btw, you also made me learn to edit the initrd, which is pretty cool to.
Karl Godt wrote:
deniros wrote:It is definitely a configure issue in my case.
Since, the discard option works on the second partition, sda2, on that same drive. I've put an entry for that in /etc/fstab. And i tested it.
sda1 is automatically mounted, not using /etc/fstab, since puppy is installed on it (frugal) and the save file is there as well. I just don't know where i can modify the mount options of this automatically mounted partition.
Karl Godt wrote:To mount -o discard apparently is only a kernel version OR configure issue :
# mkdir /mnt/sdb2
# mount-FULL -t ext4 -o discard /dev/sdb2 /mnt/sdb2
# mount
/dev/sdb2 on /mnt/sdb2 type ext4 (rw,relatime,barrier=1,data=ordered,discard)
# uname -r
2.6.37.4-KRG-i586TSC-64GB-1
# mount-FULL -V
mount (util-linux 2.13-pre7)
I meant kernel compile configuration (.config) , not Puppy specific OS configuration .

Nevertheless , /etc/fstab exists in the initrd.gz too and will be used at boot first and after init has switched to the top of the layered filesystems the normal /etc/fstab file may be used by /etc/rc.d/rc.sysinit .

Puppy uses /etc/fstab mainly for /proc and /sys .

mount -a does not get used by Puppy by default .

You would need to adjust initrd.gz as i had shown 6 or 7 posts above .
Navigate to the how to section here , editing initrd also gets discussed there :
GUI to edit initrd.gz

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#15 Post by Karl Godt »

WOW , without testing the code myself , it worked !!

I feel honored about that , deniros !

It is ok not to listen because i also may read code wrong , especially reading 1000+ lines code the first time !

Proost && Santé !

Post Reply