I want to mount a particular folder as /system.
I tried mount -t ext2 -o loop /sd-ext/rom/system /system
I get mount: mounting /sd-ext/rom/system /system failed: Block device required
Im using android, so im limited to android shell and busybox.
I'm not familiar with Android, but if you want to mount a directory instead of a device you have to use mount with the --bind option.
If it's really a file then maybe your Android has no loop device support. Do you have any /dev/loop* devices?
Related
I am using Ubuntu 22.04 and would like to mount an opened LUKS device (USB pen drive) in /media/user_name/... for it to show up in the Ubuntu file explorer.
When inserting the drive a dialog immediately opens asking for a password to unlock the drive. Since I am using a key file to unlock the device I cancel the dialog. At this point the drive is visible in file explorer and can be ejected.
In a terminal, I open the device with sudo cryptsetup open /dev/sda1 LuksUsb --type luks2 --key-file the_key_file. The drive now disappears from the file explorer.
With lsblk -o NAME,TYPE,SIZE,FSTYPE,UUID,MOUNTPOINT I see sda, sda1, and LuksUsb.
sda1 has filesystem type crypto_LUKS and LuksUsb no fstype. The device is now also in /dev/mapper/LuksUsb.
Next I want to mount the device in /media/user_name/Luks.
First, creating Luks dir in /media/user_name/ then mounting with mount /dev/mapper/LuksUsb /media/user_name/Luks.
The resulting error message:
mount: /media/user_name/Luks: wrong fs type, bad option, bad superblock on /dev/mapper/LuksUsb, missing codepage or helper program, or other error.
I have tried explicitly passing a filesystem type (-t ext4 in this case) to the mount command, but the outcome is the same.
Also tried mount -t ext4 /dev/sda1 /media/user_name/Luks yields error message mount: /media/user_name/Luks: /dev/sda1 already mounted or mount point busy.
Insights much appreciated.
Running LXDE on Raspbian.
I want to run a script on a usb flash drive when the device is plugged. Any flash drive, not a specific one.
This is to provide code updates to customers without requiring a keyboard or mouse attached to one of several rpis in a system (they have displays but no input devices). The customer will download a file to a thumbdrive on his own device and then insert it in one of four rpis in the system. The script will "do what it needs" to backup old files and scp new ones to the correct hosts and remote directories in the system
I can write a udev rule that creates a symlink to the flash drive when plugged. The symlink shows up under /dev But, I can't cd into that symlink--I probably have to do a mount first.
By observation, LXDE seems to automount a USB flash drive in /media when plugged. I don't see the name of the mount point (e.g. /media/B85D-6433) when using:
udevadm info -a -p $(udevadm info -q path -n /dev/sda1) | grep -i 6433
or
udevadm info -a -p $(udevadm info -q path -n /dev/sda1) | grep -i B85D
So, I can't figure out where the LXDE will mount the drive without first knowing its name.
1) Is there a way to determine the name of the directory under /media that LXDE will use for the mount point? I could keep a list of what was in /media before and after the plug event and determine it that way, but maybe there's a better way?
2) Instead, should I mount the symlink under /dev to a different place then excecute the script on the usb drive via this new mount point?
3) Other way?
Thanks!
I've been using this line in /etc/fstab for mounting a storage device to my host:
//url.to-my-storage.com/mystorage /mnt/backup cifs
iocharset=utf8,rw,credentials=/etc/backup-credentials.txt,uid=1000,gid=1000,file_mode=0660,dir_mode=0770
0 0
I was mounting it to another host, and I ran this to protect the files from change through the new host:
chmod -R 444 /mnt/backup
(I tried to protect the storage from writing from this host, which turned out to change the mode of all the storage files)
I assume the missing executable permissions what causing me this:
$ sudo mount -a
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
I tried unmounting and mounting again, that didn't help, got the same permission error when using the mount command.
ls the dir shows this:
$ ls -la /mnt/backup
?????????? ? ? ? ? ? backup
HELP !
Dismounting a "Locked Out" Network Drive
To dismount a "locked out" network drive, you can try to force the unmount:
umount -f -t cifs /mnt/backup
If you are having trouble dismounting a drive, make sure that you don't have a console open somewhere where the current working directory (CWD) on the drive which you are trying to dismount, or have a file open in an editor or player somewhere or such.
Properly Mounting a Network Drive
You should add your permissions in your mount options rather than trying to apply them afterwards. You would want to replace these mount options:
rw,file_mode=0660,dir_mode=0770
with
ro
Currently you are mounting your CIFS drive as read-write (rw), giving files read-write permission (file_mode=0660) and directories read-write-execute (dir_mode=0770). Simply mounting the drive as read-only (ro) should suffice. (If you do need to fine tune the file and dir modes, rather use umask.)
I would also advise you to double check whether you are using uid and gid correctly: if the user ID or group ID used gets deleted, that could also lead to problems.
References
https://linux.die.net/man/8/mount
https://en.wikipedia.org/wiki/File_system_permissions
https://oracletechdba.blogspot.com/2017/06/umount-lsof-warning-cant-stat-cifs-file.html
https://stackoverflow.com/a/40527234/171993
I'm using a Debian wheezy stable and I'm trying to automatically mount a specific usb device in a designated directory when it's plugged (not at boot time or with the mount command).
I know how to mount my device in the directory I want with /etc/fstab and the mount -a command with this /etc/fstab:
UUID="xxxxxxxxxxxxxxxx" /media/myFolder ntfs auto,exec,rw,user,suid,uid=1000 0 0
I also know how to use usbmount to mount a device when it is plugged.
My problem is that usbmount mounts the device in a folder /media/usbX and not in the directory specified in fstab.
I didn't find how to change the configuration of usbmount to make it respect the /etc/fstabfile.
Is it possible and if so how can I do it?
Check out MOUNTPOINTS in /etc/usbmount/usbmount.conf.
# Mountpoints: These directories are eligible as mointpoints for
# removable storage devices. A newly plugged in device is mounted on
# the first directory in this list that exists and on which nothing is
# mounted yet.
MOUNTPOINTS="/media/usb0 /media/usb1 /media/usb2 /media/usb3
/media/usb4 /media/usb5 /media/usb6 /media/usb7"
Environment is in virtual box,ubuntu 12.04. It has 2 disks, /dev/sda1 and /dev/sdb1 are both ext4 type filesystem.
Since /dev/sdb1 is add after system installed, so I want to mount it manually. I'd try this command:
sudo mount -o user,defaults /dev/sdb1 ~/project
No errors report. Then I get mount info by mount:
/dev/sdb1 on /home/igsrd/project rw,noexec,nosuid,nodev
But when I ls -l to see /home/igsrd I found its permission is still belongs root, so I can't touch anything in it. Why it still belongs root?
I have another machine running ubuntu 12.04,too. I mount another partition with same option will be fine, correct permission(ownership). Are any differences between them?
*nix permissions on a filesystem that supports them natively, e.g. ext4, will be maintained regardless of how it is mounted when using a proper filesystem driver, e.g. the native ext4 driver built into Linux.
Why don't you just (while still root) do this:
chown -R <your-user-name> ~<your-user-name>/project
?