Tag Info

Hot answers tagged

6

Have a look under the /sys/ directory. In particular, /sys/block/ contains symlinks to block devices in /sys/devices/. /sys/block/sdX/removable looks like it will read as 1 for a removable device, and 0 otherwise. This gives you a basic check for removability. I'm not sure if there's a better way to check if it's a USB device, but readlink /sys/block/sde ...


5

I think you're looking for pmount. If you want automatic mounting upon insertion, see Automounting USB sticks on Debian. The program that reacts when a new device appears is udev, so automatic mounted is triggered by a udev rule. The usbmount package provides udev rules to automatically mount USB storage devices and a few others. You cannot automatically ...


4

If you are able to open a block device O_EXCL, it isn't in use by the kernel (O_EXCL takes a device lock in this particular case). lsof (/proc scanning) should find any other users (VMs might have the device open, and often fail to open exclusively).


4

You mentioned you are using the FAT32 file system. FAT, as well as NTFS are case insensitive FSes. I am assuming the driver does uppercase only to make sure there is not >1 file in the dir with the same name (though with different casing). The problem you describe has been around for a while. See this thread from 2008 for example. I suggest using a ...


3

+1 for Gabriel's answer - O_EXCL is exactly the solution I used in this scenario. Here's the Perl function I wrote to check if a device is in use: use Fcntl; use Errno; sub device_in_use($) { my $device = shift; # open with O_EXCL returns EBUSY if a device is in use # http://www.kernel.org/doc/man-pages/online/pages/man2/open.2.html return ...


3

Ok, so to pull this in a list, you can use the same command I gave you before, but just drop the removeable requirement: % for blk in $(lsblk -ndo name) ; do > udevadm info --query=all --name "$/dev/$blk" |\ > grep -q ID_BUS=usb && printf \ > 'findmnt %s -no TARGET ;'\ > "/dev/$blk" ...


3

You are asking for the impossible. Anyone who has the password to the superuser (root) account has full access to the entire system. root needs that sort of access to be able to administer the system. There is no user account more privileged than root in Linux. Based on what you wrote in the comments, there are a few obvious alternatives: Don't give the ...


3

Yes, on the other system if you have a user with same user ID then he/she will have access to it.


3

There are many ways to format a USB Command line Type this command in the terminal which will help you identify the USB name i.e: sdb,sdc,etc... sudo fdisk -l Make sure the USB is not mounted, if yes then you need to unmount it: umount /dev/sdX Replace sdX with your device name Delete any existing partitions (from the SD card only). Enter the ...


3

The locate database is generally configured to omit files on removable disks, since they can't be assumed to be there later. It can be configured through a file such as /etc/updatedb.conf (the location depends on which of the several locate programs you use and how it is configured by your distribution). For a removable disk, it is probably better to keep ...


3

You don't have to export the VG, that's used to migrate a VG from one system to another. Simply vgchange -an vgname to deactivate all logical volumes on the volume group you wish to unplug. Later, after plugging the device back in, vgchange -ay vgname will reactivate all logical volumes in your vgname VG and then you can mount LVs and use. Device ...


3

Most “live CD” distributions can be installed on a pen drive instead of a CD. Then you can use the rest of the pen drive (if it's large enough) as storage. For example, for Ubuntu, prepare a “live CD” on a USB pen drive. The pen drive creator utility will let you choose how much space to devote to storage. Alternatively, just do a normal installation that ...


3

First, in order to work with NTFS (a proprietary file system) you need to install ntfs-3g: # pacman -S ntfs-3g There is a page on the the Arch Wiki that will step you through configuration options, such as automounting and user access...


3

You can fix it (each time it happens) with this command: find local_directory_name -depth -exec sh -c 'dir="$(dirname "$0")"; FILE="$(basename "$0")"; lowfile="$(echo "$FILE" | tr "A-Z" "a-z")"; if [ "$lowfile" != "$FILE" ]; then mv "$0" "$dir/$lowfile"; fi' {} ";" Type this all as one line (replacing local_directory_name with the name of the directory ...


2

I heartily recommend Puppy Linux in on of its many derivatives: I use it every day on my computers and found it will simply work, easily. Also it will fully load in RAM so you don't have to bother with drive speed. It has all what you ask and works on most hardware also where many other distro fail. Not recommended if you are scared to running always as ...


2

For your requirement, I will suggest you to go with dsl


2

Filesystems designed for unix, such as ext4, track the user via a number, the user ID. The user name is not recorded. You can see your own user ID with the command id -u. You can see the user ID who owns a file with ls -ln /path/to/file. If you take an ext4 filesystem to a different machine, the files will still have the same permissions, and they will have ...


2

The config file is here: /etc/updatedb.conf, so if you didn't add anything, just mount your HDD, and do updatedb, then you would be able to search for files on external HDD partitions.


2

Where I worked we had a very similar situation and this might sound heavy handed but we literally filled the USB ports with epoxy.


2

All block devices have a removable attribute, among other block device attributes. These attributes can be read from userland in sysfs at /sys/block/DEVICE/ATTRIBUTE, e.g. /sys/block/sdb/removable. You can query this attribute from a udev rule, with ATTR{removable}=="0" or ATTR{removable}=="1". Note that removable (the device keeps existing but may have ...


1

You must assign USB devices to the VM. That is easily possible via the VirtualBox menu.


1

The backup will be a lot faster if you only back up what's changed. This needs to be done at the file level, with encrypted containers mounted, because files carry a timestamp which allows the backup tool to skip files that haven't been modified since the last backup. To do the file copying, rsync is the tool of choice. You need to synchronize each ...


1

With a little effort I found the answer to my second question: cat /sys/block/sda/removable


1

I think I have it: Replacing grep -Hv 0 /sys/block/*/removable by grep -Hv ^ATA\ *$ /sys/block/*/device/vendor seem work: export USBKEYS=($( grep -Hv ^ATA\ *$ /sys/block/*/device/vendor | sed s/device.vendor:.*$/device\\/uevent/ | xargs grep -H ^DRIVER=sd | sed s/device.uevent.*$/size/ | xargs grep -Hv ^0$ | cut -d / -f 4 )) for ...


1

Turns out you have to install gvfs and polkit-gnome to make this work. After logging out and in again Thunar supports mounting USB devices.


1

It sounds like you are looking for a persistent USB install? Is that correct? The basic procedure is to install your Linux distribution on to the USB drive and then boot from it. The trick is making the Linux install persistent, the basic procedure is (shamelessly copied adapted from here) Boot into a Live Session of your Linux of choice (Ubuntu in this ...


1

Ok, it's been a long time, but I'll still answer my question with the best option I found as of now. The best way is to create a udev rule, associated with some scripts (that will create / remove directories and mount / unmount removable devices), and attached to partition udev device event type. 1 - Creating add / remove scripts Add this script ...


1

I like to use this one-liner. find /dev/disk/by-path -name "*-usb-*" -not -name "*-part*" -exec readlink -f {} \; It will 1) list all devices with USB in its path somewhere, 2) filters for partitions and finally 3) reads the link it points to. Example output: /dev/sdc Important notes: It will not work for external disks connected using another bus, ...


1

@umair i am not sure why sdb is showing as removable , could you post the o/p of this script for device in /sys/block/* do if udevadm info --query=property --path=$device | grep -q ^ID_BUS=usb then echo $device fi done


1

To find your USB drive, first issue: blkid then you will see something like: /dev/sdxy: LABEL="USB_DRIVE_LALBEL" UUID="USB_DRIVE_UUID" TYPE="IT'S_FILE_SYSTEM_TYPE" where as /dev/sdxy is your usb drive which x={a,b,c or d} and y={1,2,3,...} now issue: mount -l|grep /dev/sdxy it will show (something like): /dev/sdxy on /PATH/TO/USB/MOUNT/PLACE type ...



Only top voted, non community-wiki answers of a minimum length are eligible