How to run c code in Linux if linux is installed on usb -
i've installed linux mint on usb hard drive got slow. want compile , run c code. compiled linux in usb , i've store programme in 1 of hard drive ntfs/fat partitions i'm getting bash permission denied error should run code? cannot store programme in usb(linux partition)
probably problem nfs/vfat systems mounted noexec
flag or maybe showexec
flag. instruct kernel not run executable these partitions (a security measure).
if showexec
, matter of naming executable .exe
, .com
or .bat
extension (yes, if linux executable, vfat driver uses extension infer executable permission bit).
if noexec
, read on...
on older kernels bypass /ld-*.so
trick, man mount
comments:
noexec: [...] (until possible run binaries anyway using command /lib/ld*.so /mnt/binary. trick fails since linux 2.4.25 / 2.6.0.)
if guess correct, have several options:
a. remove flag partition, command root:
mount -o remount,exec <mount-point>
b. find out why partitions have flag, programme (gnome-disks
or whatever) , alter it.
c. compile programme partition, if not in usb partition, illustration in tmpfs
:
mkdir exe sudo mount -t tmpfs exe exe
and then, when compile program:
gcc test.c -o exe/test
but beware! tmpfs
volatile , disappear when umount or shut downwards machine. can create permanent partition-in-a-file:
truncate -s 512m exe.img mkfs.ext4 exe.img mkdir exe
then, mount image each time boot machine:
sudo mount -o loop exe.img exe
c linux
No comments:
Post a Comment