Hot answers tagged

9

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 ...


9

LVM is not overkill if you have 17 partitions. (IMHO) As for the partition limit, it just happens to be the default. Probably no one expected that many partitions on a device that used to have only a few megs. /usr/src/linux/Documentation/devices.txt: 179 block MMC block devices 0 = /dev/mmcblk0 First SD/MMC card ...


5

While accessing it by /dev/sdXy is risky, a more accurate identification may be done by UUID. Since you mention (at some point) changing the usb stick, to maintain compatibility, you may want to identify your usb stick by a label. To do so, you can: /dev/disk/by-label/YourLabelHere. Note that you need to set the label to a new usb stick before running the ...


4

I believe you can use pmount instead. It's in the Debian 7.7 repos. $ apt-cache search pmount libpmount-dev - portable mount library - development files libpmount0.0 - portable mount library - shared library pmount - mount removable devices as normal user Usage $ pmount -h Usage: pmount [options] <device> [<label>] Mount <device> ...


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 ...


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 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 ...


4

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.


4

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

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 ...


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

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

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

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


3

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 ...


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

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 ...


3

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 ...


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

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

This is how I address this problem, but generally as Sato Katsura told you, you need to write a udev rule. Plug in your device, check which device it got (for example by watching dmesg). As superuser call udevadm info --query all /dev/sdc (or whatever). Setup a udev rule, here is an example for my pocketbook. The fields ID_SERIAL_SHORT and ID_FS_UUID I ...


3

I recommend visiting Filesystem Hierarchy Standards. /media is mount point for removable media. In other words, where system mounts removable media. This directory contains sub-directories used for mounting removable media such as CD-ROMs, floppy disks, etc. /mnt is for temporary mounting. In other words, where user can mount things. This directory is ...


3

Unfortunately, there's not much you can do, other than replace the hard disk or get an external disk. You can, of course, try to reduce the amount of disk space you're using, but most modern Linux distros will eat 20 gigs pretty quick. That means you either trim out everything you don't need, or possibly change distributions to one that's a bit more trim ...


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

The shutdown process somewhere includes umount -a that's effectively the same as "safely remove" Once the shutdown is finished it's safe.


2

Systemd reimplements many functionalities previously scattered over the whole OS (eg. in udev daemon), and is able to recognize that device was just plugged in or out. At the same time, systemd holds all system services configuration: what need to be run, how to run it etc. And simply, it has all knowledge needed to start, stop, or even reconfigure services ...


2

Most distributions have a command called by blkid. blkid will give you a unique identifier for each drive attached to you linux box. Fstab can uses this identifier, replace the /dev/sdc1 with UUID=XXXXXXXXXXXXX. This means that regardless of the user-space designation (e.g. sdc1 scb2 et cetera) your OS will mount it correctly.


2

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


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 ...


1

Have a look at http://www.pendrivelinux.com/ -- they have an installer for putting just about any Linux distro on a USB drive.



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