mounting devices not allow binaries - linux

what command will mount device /device/sdal to the mount point /mnt/usb with a filesystem type of ext 3 and not allow binaries executed from the device

mount -t ext3 -o noexec /dev/sda1 /mnt/usb

That should do it:
mount -t ext3 /dev/sda1 /mnt/usb -o noexec

The noexec option should do this. If you're using the user option, noexec is implied.
http://linux.die.net/man/8/mount

Related

Toggle readonly filesystem for changes

I have a readonly filesystem on my bootable usb drive.
I want to modify some text files in there and then bring it back to readonly after modify it.
I tried :
sudo hdparm -r0 /dev/sdb
I also tried :
mount -o remount,rw /dev/sdb
mount: /dev/sdb: mount point not mounted or bad option.
mount -o remount,rw /dev/sdb1
cannot remount /dev/sdb1 read-write, is write-protected.
But it's stays readonly.
I do not want to make any other changes to the partition it's important to keep all the rest of the partition/mbr as is.
Any idea?

Programmatically obtaining USB file system format

I need to mount a USB drive to an embedded system, running Linux. The USB could be in FAT, NTFS or ExFAT format.
How can i handle this in code so that I pass proper type in mount command such as
mount -t vfat /dev/sda1 /mnt
So I have tried mount with:
mount -t vfat,ntfs /dev/sda1 /mnt
This command gives invalid argument, but it successfully mounts the USB if USB is in NTFS or VFAT format. However if i try to give
mount -t vfat,ntfs,exfat /dev/sda1 /mnt
The command fails.
Any pointers will be really helpful.
From the mount manual page:
If no -t option is given, or if the auto type is specified,
mount will try to guess the desired type. Mount uses the blkid
library for guessing the filesystem type...
Is libblkid available for your embedded system?
Try:
mount -t auto /dev/sda1 /mnt
or
mount /dev/sda1 /mnt
And as mentioned in the comments, make sure the kernel on your embedded system supports exfat.

Mount Squashfs as Root in initramfs Raspbian

I'm currently trying to make my raspbian boot from a squashFS image through initramfs.
The squashfs image is on file system /dev/mmcblk0p1, so I mount this prior to mounting the Image.
Unfortunately I'm stuck at mounting the SquashFS Image file.
I tried mounting through
mount -o loop
but I always get
mounting /dev/loop0 on /mnt/root failed: No such device
So I tried to mount it through loop manually. The problem is, that mounting the /dev/loop0 fails with the same Error as above.
This is my init so far:
#!/bin/busybox sh
# Mount the /proc and /sys filesystems.
mount -t proc none /proc
mount -t sysfs none /sys
#create loop devices
mknod /dev/loop0 b 7 0
mkdir /mnt/root
# Mount the boot partition
mount -o ro /dev/mmcblk0p1 /mnt/boot
sleep 5
# Mount the root FS with losetup
echo "Mounting with losetup"
losetup /dev/loop0 /mnt/boot/SYSTEM
mount /dev/loop0 /mnt/root -t squashfs
echo "Done"
#mount -o ro,loop -t squashfs /mnt/boot/SYSTEM /mnt/root
# Use Fallback mounting failed
if [ ! -e /mnt/root/home ]
then
echo "MOUNTING SDA1"
mount /dev/sda1 /mnt/root -t ext4
fi
# Clean up.
umount /proc
umount /sys
umount /mnt/boot
# Boot the real thing.
exec switch_root /mnt/root /sbin/init
Checking
losetup /dev/loop0
tells me, that the squashfs Image has been attached to loop0.
Does somebody know where to start?
I came across your question because I ran into the same thing today while building my own initramfs. I did some more digging and found this:
http://www.silas.net.br/doc.notes/unix/linux/busybox-troubleshooting.html
Then it dawned on me that I hadn't built squashfs into the kernel or loaded the module. After I did that, everything worked!
In case you haven't, make sure your kernel supports squashfs.

UBIFS mount in busybox via fstab does not recognize relatime option

I am getting this error when I try to mount my UBIFS filesytem:
mount -o remount,rw /config
UBIFS error (pid 1265): ubifs_parse_options: unrecognized mount option "relatime" or
missing value
The content of my fstab is :
root#drgos:~# cat /etc/fstab
# WARNING: this is an auto generated file, please use uci to set static filesystems
/dev/ubi0_0 /config ubifs ro 0 0
And when I type mount the result is :
root#drgos:~# mount
rootfs on / type rootfs (rw)
none on /proc type proc (rw,relatime)
none on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime,size=512k)
none on /dev/pts type devpts (rw,relatime,mode=600)
/dev/ubi0_0 on /config type ubifs (ro,relatime)
none on /proc/bus/usb type usbfs (rw,relatime)
I do not understand why I have the option relatime since that one is not present in my fstab!
I am using BusyBox v1.11.2 (2014-01-13 09:35:41 CET) multi-call binary.
These options are dependent on the Linux kernel version. relatime is a general mount options. relatime is the default for newer Linux kernels. Other filesystems may quietly ignore unknown options, whereas ubifs is failing. You can try mount -o remount,rw,noatime,norelatime /config. Your mount command shows the /config directory is mounted with relatime; this is information that busybox mount applet collected.
This information is collected with the getmntent_r() function. If busybox is dynamically linked, then the 'C' library may be giving this information as part of the *mnt_opts* string.
The idea with mount -o remount,rw,noatime,norelatime /config is to try and over-ride this information so that UbiFs will be happy with its mount options. The other way is to simply umount and then mount again manually.
umount /config
mount -t ubifs /dev/ubi0_0 /config
This way previous mount information will not be retrieved.

Ubuntu mount -t command

I use following command to mount "/dev/sdb1" to "/storage" directory:
mount -t ext3 /dev/sdb1 /storage
After run above command, I can use "df -h" can see it:
/dev/sdb1 147G 188M 140G 1% /storage
But after i restart the server, it disappear, and i have to run mount command again.
Is there a command that can keep the mount even if i restart the server?
Add the following line to your /etc/fstab file:
# device name mount point fs-type options dump-freq pass-num
/dev/sdb1 /storage ext3 defaults 0 0
You can run (as root):
echo "/dev/sdb1 /storage ext3 defaults 0 0" >> /etc/fstab
You need to add relevant information to /etc/fstab.

Resources